I'm creating a search function for my program, and need some help with SQL. Until now I have been using simple SQL query like
"SELECT post1 FROW table1 WHERE a=b"
and put it into arrays. Then using that info to do another query, put it into arrays, and so on.
I know there are ways to improve my SQL querys like this
"SELECT table1.post1, table2.post2 FROM table1, table2 WHERE a=b"
(more or less)
I want to query (using JOIN?) 3 tables, where some of the posts are only intermediate data to find posts in other tables.
Table 1:
UserName
UserID
Table 2:
Date
UserID
CustomerID
Table 3:
Order
CustomerID
Result:
Date,Order
I have the UserName, and from that I need to get the UserID to get to the latest Date and corresponding CustomerID. Then use the CustomerID to get the Order.
All UserName has 3 UserID (Only one are in use at any given time).
All Dates has between 1 and 500 CustomerID
All CustomerID has 1 Order