2011-01-16 12 views
0

私はSQLクエリをまとめようとしていますが、私はすべて混乱してしまいました。私は必要なものを普通の言語で書いています。PHP/MySQL - クエリの作成

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 

すべてのヘルプは素晴らしいだろう:)

EDIT:

表のintrolesを次のようにテーブルの構造は以下の通り

id 
user_id 
introle 

表の可用性が

次いています
id 
user_id 
date 
+0

問題のテーブルの構造リストと、反対の主な要素/基準をダンプすることができます。必要なクエリを書き出すのに役立ちます。 – DRapp

+0

私はそれを編集しました、それが助けてくれることを願っています – Cecil

+0

...あなたは建物の疲れたバージョンを意味しますか? – regilero

答えて

0

あなたは、SQLクエリ内のすべての変数の

'$variable' 

代わりの

$variable 

を試すことができますか?

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

だから何ですか?それは動作しますか? – Andreyco