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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL help

Status
Not open for further replies.

mbarrett

IS-IT--Management
Jan 4, 2001
14
0
0
US
My SQL is pretty sketchy so I was wondering if someone could shed some light on my problem.

I have two tables, one calles PLANTS and one called DATA.

The PLANTS table contains two columns, one is plant names and the other is a unique identifies (1, 2, 3...).

In the DATA table I have a few columns with plant information, one of which is a the unique identifier from the PLANTS table, so I know which plant the record set is referring to.

Now when I run a SELECT * FROM DATA I obviously get back everything from the DATA table and I print this to an HTML table. What I want to do is print out the name of the plant from the PLANT table, rather than the unique identifier from the DATA table.

So my question is: Is there a way to cross-refernce the plant ID number from the DATA table and replace it with the plant name (using JOIN or AS maybe)?

Thanks,
Matt
 
SELECT * FROM DATA JOIN PLANTS ON DATA.PLANTID = PLANTS.PLANTID

Actually, I'd specify the columns rather than use the * because you do not need to return the value of PLANTID and this structure would actually return it twice (once for each table).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top