我在这里做错了什么。我已经遵循了很多例子,但似乎无法让这个工作。 我有2张桌子
表=>用户
user_id
user_name
user_email
user_password
user_country
user_dobdate
user_company
user_code
user_status
user_type
表=>应用
apply_id
apply_from
apply_leave_type
apply_priority
apply_start_date
apply_end_date
apply_halfday
apply_contact
apply_reason
apply_status
apply_comment
apply_dated
apply_action_date
SQLI QUERY
$query = $db->select("SELECT users.user_id, app.apply_from FROM users INNER JOIN applications ON users.user_id = app.apply_from WHERE users.user_code='1'");
$rows = $db->rows();
foreach ($rows as $apply){
$apply_id = $apply['apply_id'];
$apply_from = $apply['apply_from'];
错误消息
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in xxxxxxxxxxxxxxx line 26
答案 0 :(得分:4)
您的查询;
SELECT users.user_id, app.apply_from
FROM users
INNER JOIN applications
ON users.user_id = app.apply_from
WHERE users.user_code='1'
...对表app
使用别名application
,但不声明它。
INNER JOIN applications app
答案 1 :(得分:3)
您已将applications
表的别名错过app
中的join
。请尝试以下方法:
SELECT users.user_id,app.apply_from
FROM users
INNER JOIN applications app ON users.user_id = app.apply_from
WHERE users.user_code='1'
答案 2 :(得分:2)
将applications
表格缩写为“app”:
SELECT
users.user_id,
app.apply_from
FROM
users
INNER JOIN
applications AS app
ON
users.user_id = app.apply_from
WHERE
users.user_code='1'