Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

joining access tables 1

Status
Not open for further replies.

jcroft

Programmer
Aug 23, 2001
52
US
I have two tables in one database. I need to "SELECT * FROM table1 and ORDER BY (a field in table 2)". Is this where I need to have a cross join (Cartesian Product), and does that work with Access? The two tables have at least one field with same name but different data...whatamess.
I don't have enough experience to make best solution...any suggestions would be appreciated.
 
Well, it's not the name that matters, it's the data -- in order to be able to ORDER a query from table1 by a field in table2, you will have to have a column with like data in it, and that's the one that you will JOIN on, and once the query is JOINed, then you can ORDER BY that other column.

It might look like this:
SELECT col1 FROM table1 t1 INNER JOIN table2 t2 ON t1.col1 = t2.col2 ORDER BY t2.col2

so that your resulting dataset doesn't have any data from table2 in it, but it is ORDERed BY the column there.

paul
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top