yewu
注册会员

初级会员
UID 16513
精华
0
积分 114
帖子 109
金钱 114 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2002-9-15
状态 离线
|
union联合两条查询为一个结果集的问题
"SELECT contacts.*, notes.note_text, notes.note_date FROM contacts, notes WHERE contacts.contact_id = notes.note_contact ";
"SELECT contacts.* FROM contacts LEFT JOIN notes ON contacts.contact_id=notes.note_contact WHERE notes.note_contact is NULL";
我想要合作这两条查询为一条.
第一条的结果集为: notes表中有对应行的contacts表中所有的行 以及notes表中的对应行.
第二条的结果集为:notes表中无对应行的contacts表的所有行
对union的用法不熟, 看了半天手册看出了我的错误在哪, 却不知如何解决. 帮帮忙
|
|