[thelist] SQL: Help with a simple join

Stephen Caudill SCaudill at municode.com
Wed Jun 18 13:47:36 CDT 2003


Casey Crookston bespaketh on Wednesday, June 18, 2003 2:34 PM:

> Two tables in question: tb_employees and tb_titles.
> 
> tb_employees:
> 
> +-----------------+-------------+-----------+
>>     first_name       |    last_name  |   title_id     |
> +-----------------+-------------+-----------+
> 
> tb_titles:
> 
> +------------+-------+
>>     title_id     |    title   | +------------+-------+
> 
> I now need to dispaly the first names, last names, and titles.  Help
> me out a little with the SQL syntax:
> 
> SELECT first_name.a, last_name.a, title.b, FROM
> tb_employees.a, tb_titles.b
> WHERE title_id.a = title_id.b ORDER BY last_name
> 
> Here's the error:
> 
> Error Type:
> Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
> [Microsoft][ODBC Microsoft Access Driver] The SELECT statement
> includes a reserved word or an argument name that is misspelled or
> missing, or the punctuation is incorrect.
> /boser/about/ind.asp, line 9
> 
> Thanks!!!
> 
> Casey

Casey,
  The select statement should be:

SELECT a.first_name, a.last_name, b.title
FROM tb_employees a, tb_titles b
WHERE a.title_id = b.title_id 
ORDER BY a.last_name

hth,
Stephen Caudill
http://www.mechavox.com


More information about the thelist mailing list