我需要一些帮助,在这里我有这个2个表:选择..哪里...或从2个表
table "clients"
+------+-------------+-----------+
id | email | otherinfo|
+------+-------------+-----------+
1 |[email protected] | ..... |
+------+-------------+-----------+
2 |[email protected] | .... |
+------+-------------+-----------+
table "comptes"
+------+-------------+---------------+
id | login | id_clients |
+------+-------------+---------------+
1 | test | 1 |
+------+-------------+---------------+
1 | test2 | 2 |
+------+-------------+---------------+
etc. | etc. | etc.. |
+------+-------------+---------------+
在我的网站,当用户箱子的账户,他给两个表的信息。所以我想加入他们,像这样
'select clients.email,comptes.login
from clients,comptes
where clients.email='[email protected]'
or comptes.login ='test';
之前对其进行测试,如果登录或电子邮箱存在于数据库中,但该查询返回空结果,我累了其他组合,但没有放弃。所以我是谁搞乱正确的结果这里
感谢,这工作非常出色,但第二个查询返回该错误“每一个派生表必须有它自己的别名” – user1559104 2012-08-14 20:47:50
@ user1559104。 。 。我不确定这是为什么。你有最后的“t”吗?我检查SQL小提琴,并且甚至在union all之前都不允许别名。 – 2012-08-14 21:08:38
我没有删除最后的“t”,我用phpmyadmin使用mysql。无论如何,我使用第一个解决方案,谢谢 – user1559104 2012-08-14 21:14:30