Hallo habe ein tierisches Problem.
orginal
das neue
so das using oder on fehlt weiß ich. aber wo und was schreibe ich da rein?
Meine Tabellen
status:
id ---- userid ---- text
1 ---- 1 ---- te01
2 ---- 1 ---- te02
3 ---- 2 ---- te03
users:
id --- lname ---- fname
1 ---- ln02 ---- fn01
2 ---- ln02 ---- fn01
3 --- ln02 ---- fn01
die ausgabe sollte sein:
ID ---- name ----- text
( von status) ---- ( fname,lname) ---- text aus status
Kann mir da irgendjemand mal bitte helfen?
komme einfach nicht weiter
orginal
PHP:
$sql = "SELECT * FROM `status`";
$result = mysql_query($sql);
while ($num_row = mysql_fetch_array($result))
{
// user finden in der Tabelle users
$sql_user = "SELECT * FROM `users` where id='$num_row[userid]'";
$result_user = mysql_query($sql_user);
$user_row = mysql_fetch_array($result_user);
das neue
PHP:
$sql="SELECT *,users.lname,users.fname FROM status LEFT JOIN users where users.id=status.userid";
Meine Tabellen
status:
id ---- userid ---- text
1 ---- 1 ---- te01
2 ---- 1 ---- te02
3 ---- 2 ---- te03
users:
id --- lname ---- fname
1 ---- ln02 ---- fn01
2 ---- ln02 ---- fn01
3 --- ln02 ---- fn01
die ausgabe sollte sein:
ID ---- name ----- text
( von status) ---- ( fname,lname) ---- text aus status
Kann mir da irgendjemand mal bitte helfen?
komme einfach nicht weiter