PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Basic SQL Question

One table references another table:
Code:

TABLE1
Name ID
Test1 08
Test2 05

TABLE2
ID Phone
05 555-1234
08 555-1111


I want output like this:
Test1 555-1111
Test2 555-1234

It seems like I need nested SELECT statements, if that is the right way to do this is SQL?

Dan East
No you do not need nested SQL statements. This is how I would do it.

Code:

SELECT TABLE1.Name, TABLE2.Phone FROM TABLE1, TABLE2 WHERE TABLE1.ID = TABLE2.ID
Thanks. I finally figured that out from a tutorial on the web. However the first time I tried it I did not specify the WHERE condition. So after my notebook ground away from 20 minutes and the page file reached 1.5 GB I finally started killing stuff off and stopped it. :)

Dan East
Dan East wrote:Thanks. I finally figured that out from a tutorial on the web. However the first time I tried it I did not specify the WHERE condition. So after my notebook ground away from 20 minutes and the page file reached 1.5 GB I finally started killing stuff off and stopped it. :)

Dan East


Tell me about it, still happens to me when I rush or the day is too long.
Wow drex you're being busy with SQL stuff :).

New project?
Who's drex? :) This pertains to my real job - writing healthcare related software.

Dan East
Whoops, my bad Dan :P. The last couple of days I keep messing names up... (more then usually). I have to get to bed earlier...