0

Problem:
I have two tables and those two table have one field in common which is "S_ID"

first table have 2 fields:
"S_ID", "T_ID"
second table have these fields:
"S_ID", "First", "Last"
----------------------------------

What i want to do is that i need to extract the the field "S_ID" from the first table and order them by the field "Last" which is in the other table.

any one know how i can do that in one or 2 query.
Also I am using php.

3
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by ashneet
0

Problem:
I have two tables and those two table have one field in common which is "S_ID"

first table have 2 fields:
"S_ID", "T_ID"
second table have these fields:
"S_ID", "First", "Last"
----------------------------------

What i want to do is that i need to extract the the field "S_ID" from the first table and order them by the field "Last" which is in the other table.

any one know how i can do that in one or 2 query.
Also I am using php.

select ft.s_id
from first_table ft
join second_table st on ft.s_id = st.s_id
order by st.s_id
0

Thanks A lot.
That worked really nice.
I never really understood JOIN commands, even if i read the books for SQL they only comfused me more LOL.

0

Thanks A lot.
That worked really nice.
I never really understood JOIN commands, even if i read the books for SQL they only comfused me more LOL.

A join basically combines records from more than one table. This article may help but the best way to understand is to make some test tables and actually have a go at constructing queries that utilise different types of joins.

0
SELECT * FROM first, second WHERE first.S_ID=second.S_ID ORDER BY second.Last

Does the same thing, but is much faster than a join.

Edited by pritaeas

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.