[英]Select all but on element in JOIN MySQL
I have the code here to join two tables.我这里有加入两个表的代码。 However I don't want to get the password element from the Accounts database.
但是我不想从 Accounts 数据库中获取密码元素。 How could I do this?
我怎么能这样做?
"SELECT f.*, a.*
FROM Following as f
JOIN Accounts as a on f.followingUserID = a.id
WHERE `followingUserID` = '$acID'
There is no SQL convention for "all columns EXCEPT FOR..." -- it's either all, or you define the list by hand: “除...之外的所有列”没有 SQL 约定——要么全部,要么您手动定义列表:
SELECT f.*,
a.col1, a.col2,
a.`col name using spaces not good`
FROM FOLLOWING as f
JOIN ACCOUNTS as a on f.followingUserID = a.id
WHERE f.followingUserID = '$acID'
Name the columns instead of retrieving them all.命名列而不是全部检索它们。
Instead of a.*, :代替。*, :
a.ColumnName1, a.ColumnName2, etc.... a.ColumnName1、a.ColumnName2 等......
If you don't want to select a password element you will need to change the a.*
to select each column individually ie如果您不想 select 密码元素,则需要将
a.*
更改为 select 每列单独,即
SELECT f.*, a.account_id, a.name
FROM following as f
JOIN accounts as a on f.followingUserId = a.id
WHERE followingUserID = '$acID'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.