Query the username, psw, gname, and tel of all realnames today.
Table Structure:
Table t1
Field name: t1_id, username, psw
Table t2
Field name: t2_id, gname, t1_id // here one t1_id corresponds to multiple t2_id
T3
Field name: t3_id, realname, tel, t1_id // here, a t1_id corresponds to a t3_id
The trouble is that when a realname has no content in Table t2, the username, psw, and tel of this realname should be displayed and used directly.
SQL = "select username, psw, gname, tel from t1, t2, t3 where t1.t1 _ id = t2.t1 _ id and t1.t1 _ id = t3.t1 _ id"
The result is that the t2 table must have a realname file to query its information. This is definitely not the desired result. The SQL statement is as follows:
SQL = "select username, psw, gname, tel from (t1 left join t2 on t1.t1 _ id = t2.t1 _ id) left join t3 on t1.t1 _ id = t3.t1 _ id"
In this way, the desired result is obtained.