开发者

PHP / MySQL - Constructing a Query

开发者 https://www.devze.com 2023-02-05 11:36 出处:网络
Im trying to put together a SQL query and its g开发者_高级运维ot me all confused, i have written out in normal language what i need, i cant seem to get it.

Im trying to put together a SQL query and its g开发者_高级运维ot me all confused, i have written out in normal language what i need, i cant seem to get it.

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

Any help would be amazing :)

EDIT: The table structure is as follows

Table introles has the following

id
user_id
introle

Table availability has the following

id
user_id
date


can you try

'$variable'

instead of

 $variable

for all variables in sql query?


$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})";
0

精彩评论

暂无评论...
验证码 换一张
取 消