PDA

View Full Version : Solved: SQL Syntax for querying two tables with specific columns



scaat
03-12-2010, 11:30 PM
Hello everybody

This is probably a simple job but I could not figured out how can I do it and I will go crazy.

Let's say you have two tables like this:

orders

orderno customerno orderdate orderquantity anotherfield
----------------------------------------------------------------
1 12 12/03/2010 5 xxxx
2 15 11/03/2010 20 yyyy
customers

customerno customername address city birth_date
----------------------------------------------------------------
12 mike thompson any address some city 01/01/1995
15 george brown some address lake city 05/05/1998

both of the customers are under 18 but don't worry about it :)

now, I would like to have this recordset in single query:

orderno: 1
customername: mike thompson
orderdate: 12/03/2010
orderquantity: 5

in short terms, I need the query of orders table with customer name, instead of customer number. How can I query this?

scaat
03-14-2010, 03:01 AM
I have solved the problem with following query syntax:

select orderno, orderdate, orderquantity, customerdate from orders, customers Where orders.customercode = customers.customercode and orderno = 1