我试图整理一个SQL查询,它让我感到困惑,我用正常语言写出了我需要的东西,我似乎无法得到它。
select * from introles where introle = $key
then check the table 'availability' for the user_id taken from the introles table
then out of those results, check that $_POST['date'] is not equal to the date in the 'availability' table
任何帮助都会令人惊讶:)
编辑:表格结构如下
表格介绍有以下内容
id
user_id
introle
表可用性具有以下内容
id
user_id
date
答案 0 :(得分:0)
'$variable'
而不是
$variable
对于sql查询中的所有变量?
答案 1 :(得分:0)
$query = "SELECT a.id AS aId, i.id AS iId, a.user_id, introle, date FROM availability AS a, introle AS i WHERE date != {$_POST['date']} AND a.user_id IN (SELECT user_id FROM introle WHERE introle = {$key})";