Jump to content

[SOLVED] Syntax Question


Lambneck

Recommended Posts

I think this is what you are looking for (pulled from my book, see sig):

 

SELECT * FROM table1 INNER JOIN table2 on table1.id = table2.id

// Returns all columns in table1 and table2 where the id matches

// on both tables (any rows in table1 without an id that matches

// is excluded from the resulting combined results)

 

SELECT table1.* FROM table1 INNER JOIN table2 on table1.id = table2.id

// Same as above, except only columns from table1 are included

 

SELECT table1.id FROM table1 INNER JOIN table2 on table1.id = table2.id

// Same as above, except only the id column from table1 is included

 

SELECT table.id AS tableid FROM table

// Give an alias to the column using AS (so id will result as tableid)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.