Reputation: 1129
I need to write a query but am a newbie to writing querys that involve 2 tables.
The first table 'clients' has the following columns "id, archive_reason, name, phone". The second table, 'archive' has the following columns "id, archive_reason".
What I need to do is get the archive reason based on the archive_reason in the clients table if that makes sense... and then return * from the clients table, including the archive reason from the arhive table.
Upvotes: 0
Views: 55
Reputation: 163468
SELECT clients.*, archive.archive_reason FROM clients, archive WHERE clients.id=archive.id;
Is that what you were asking for?
This is called a JOIN, and there are many more (and better) ways to do it:
http://www.w3schools.com/Sql/sql_join.asp
http://www.databasedev.co.uk/query_joins.html
Upvotes: 1