473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sql Dynamic query on Join with While loop

Expand|Select|Wrap|Line Numbers
  1. Select TM.Order_code , TI.Order_NUMBER From OrderCheck TM 
  2. Inner join OrderTable TI
  3. ON TM.OrderCode = TI.OrderCode 
  4. Where OrderDate = @L_INV_DATE 
  5. PRINT 'NULL VALUE'
  6. ELSE 
  7. PRINT 'NOT NULL'
In the above code i have write the query as per below steps but not giving the proper result , pls sort me out from this problem as the steps to create the above query as mentioned below

Select all the Order codes(order_code ) from OrderCode table
For each Order code, select the Order Number and Date from Order Master table ( OrderTable ) for all the Orders where date is same as parameter date
If there are no order for a particular Order_code, select the next Order_code from the OrderCode table and start again from step 1. Otherwise, insert the Date and Order code in the New table OrderDetail table


Here the OrderDetail table have some column common in the above mentioned table
Oct 28 '12 #1
1 2094
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code. This is your second warning.

Obviously this isn't all the code because you talk about a lot of code that isn't shown in what you posted. It's hard to spot the error if you don't include all the code that you talk about.

You also say that there are common columns between the tables but you never say what that is. Without the table design, there's no way for us to know what the common columns are.

All in all, a lot of information is missing that makes it almost impossible to answer the question. Please provide that missing information. It would also help if you posted sample data and results.
Oct 29 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: shivers3000 | last post by:
Can someone explain why $displayResults will not query twice? Scripts Objective: to take a car's VIN retrieve the car info and display in nice rows Issue with Script: The while loop displays...
4
by: bourgon | last post by:
Working on some new code, I'm coming across WHILE loops used instead of cursors. I was curious if anyone had any stats on how the speed of doing this compares to the speed of a cursor. I...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
1
by: .Net Sports | last post by:
I am trying to get all the sales reps and their combined sales totals for a given queried date, in which i loop thru (using C# while loop) the available sales reps to get their rep IDs, then match...
8
by: Nancy | last post by:
Greetings: First, I apologize if my posting format is improper. The code below does what I intended it to do, but presently only displays 1 table entry. I've grown it to this point, but really...
14
by: dawnerd | last post by:
Hi, I am developing a CMS and came across something which has never happened to me before, and I re-wrote the specific script twice, both differently, and still had the same error. I'm not sure...
0
by: adriann | last post by:
I have a strange problem whereby an attempt at a looped SQL query only passes successfully once. I get the error.. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result...
2
by: d3vkit | last post by:
Okay so I can NOT get my while loop to work. It's the most confusing thing I've ever come across. It was working fine and then suddenly, nothing. No error. The page just dies. I am using PHP5 with...
9
by: SnehaAgrawal | last post by:
Hi could you please help me with the following... The syntax for while loop is While Exists(select * from Customers) End While How can I use the above select statment using dynamic SQL?
1
by: vituko | last post by:
plpgsql (postgresql 8.3 but I can upgrade) I can open a cursor with a dynamic query (table / column variable) : -open cursor for execute '...' ; But if I want do updates... - execute 'update...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.