473,322 Members | 1,379 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,322 software developers and data experts.

sql statement writing

553 512MB
Hi

I have following SQL Queries. Is there a way to to write a single query instead somehow instead?

-Get OrderID from this query
SELECT OrderID FROM Orders WHERE CustomerID='" + reader.Item("CustomerID")


-Using OrderID, get ProductID
"SELECT ProductID FROM OrderDetails WHERE OrderID=" + readerp.Item("OrderID")

-Using ProductID, get Products
SELECT ProductName FROM Products WHERE ProductID=" + reader1.Item("ProductID")

My question is instead of quering three times, can i write a single SQL statemnt to get the final result - (ProductName)

Thanks
Qi
Jun 30 '09 #1
1 1166
ck9663
2,878 Expert 2GB
Yes, use JOIN.

Happy coding !

--- CK
Jun 30 '09 #2

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

Similar topics

26
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the...
35
by: Thomas Matthews | last post by:
Hi, My son is writing a program to move a character. He is using the numbers on the keypad to indicate the direction of movement: 7 8 9 4 5 6 1 2 3 Each number has a direction except...
10
by: ale.of.ginger | last post by:
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has...
3
by: Gordon Moore | last post by:
Hi, I'm new to using xml/xslt and although I can create an xml document using the dataset.WriteXml statement, and I have created an xslt to transform the xml into the output I want, I have to...
7
by: Bob | last post by:
Currently I am using this statement to translate 3 fields in my db thru Visual Basic. I import the data from one table to another then call the IFF statements and the NewDate to translate the...
18
by: swaroophr | last post by:
Which of switch statement and if-else statement takes less time to execute?
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
3
by: JJ297 | last post by:
Hello I'm a newbie to programming and need help writing an if statement. I have a database set up in SQL with the following fields: Category Questions Answers I only want one...
3
by: irkahs | last post by:
Hello all, I am using an SQL select statement to store the result into a variable. This variable then needs to get into a table. I am having issues with it. Kindly help. I am...
2
by: mk | last post by:
Hello, I'm trying to learn how with statement can be used to avoid writing: prepare() try: something_that_can_raise_SomeException() except SomeException, err: deal_with_SomeException...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.