gpt4 book ai didi

php - MySQLI 内部连接 ​​2 个表

转载 作者:可可西里 更新时间:2023-11-01 07:02:05 27 4
gpt4 key购买 nike

我在这里做错了什么。我遵循了许多示例,但似乎无法正常工作。我有2张 table

表 => 用户

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 = $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

最佳答案

您的查询;

SELECT users.user_id, app.apply_from 
FROM users
INNER JOIN applications
ON users.user_id = app.apply_from
WHERE users.user_code='1'

...为表application 使用别名app,但没有声明它。

INNER JOIN applications app

关于php - MySQLI 内部连接 ​​2 个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18288218/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com