sasha85
asked on
order by with join
filed data in column "subid" look like this: 12132332-43234_solg.mod.de
i got 2 tables. "table1", "table2"
table1 got columns: "subid" "name"
table2 got columns: "subid" "time"
*in the sql, the time field set as text.
how can i print the names of subid's from table1 in order of the time in table2
(mysql)
?
i got 2 tables. "table1", "table2"
table1 got columns: "subid" "name"
table2 got columns: "subid" "time"
*in the sql, the time field set as text.
how can i print the names of subid's from table1 in order of the time in table2
(mysql)
?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Remove OUTER from the statement.
ASKER
mysql="SELECT table1.name FROM table1 LEFT JOIN table2 ON table1.subid = table2.subid ORDER BY table2.time ASC"
like this? LEFT..ON..
like this? LEFT..ON..
yes, that should do it.
its left join.. on..
its left join.. on..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want to show what T2.name are missing from Tabl1 as well?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If both tables have the same number of records, use:
mysql="SELECT T1.name FROM table1 T1 INNER JOIN table2 T2 ON T1.subid = T2.subid ORDER BY T2.time"
If Table1 has more records, use:
mysql="SELECT T1.name FROM table1 T1 LEFT JOIN table2 T2 ON T1.subid = T2.subid ORDER BY T2.time Where Not IsNull(T2.Name)"
mysql="SELECT T1.name FROM table1 T1 INNER JOIN table2 T2 ON T1.subid = T2.subid ORDER BY T2.time"
If Table1 has more records, use:
mysql="SELECT T1.name FROM table1 T1 LEFT JOIN table2 T2 ON T1.subid = T2.subid ORDER BY T2.time Where Not IsNull(T2.Name)"
Mike, shouldn't the WHERE clause precede the ORDER BY clause in ur 2nd query ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i am kind of lost here...
i can't know wich onw of the tables will have more records...
what i shell use than?
i can't know wich onw of the tables will have more records...
what i shell use than?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok.ok:)
thank you all you gave me so much solutions i was shoked for a while...:)
all of them good once
thank you all you gave me so much solutions i was shoked for a while...:)
all of them good once
ASKER
i got syntax error, LEFT OUTER?