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.

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

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.

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.

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.

Thanks I will try that too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.