2016-04-30 20 views
-3

私はsqlite3を初めて使用しており、データベースで少し壁に当たっています。私は本当に他の誰かに依頼する必要はありませんので、友人が私がここに投稿して少しの助けを求めるよう勧めているようにお願いします。SQLITE3クエリ条件

Restaurant Location Chef 
'All Beef' 'London' 'Bob' 
'All Lamb' 'Paris' 'Mike' 
'All Pork' 'Berlin' 'Jill' 
'All Veg' 'London' 'Heather' 

シェフ:

は、私は2つのテーブル

レストランがあるだろう '?そこに生まれていなかったシェフと、ロンドンにあるどのように多くのレストラン'

Name  Gender  Place_Of_Birth 
'Bob'  'Male'  'London' 
'Mike' 'Male'  'Paris' 
'Jill' 'Female' 'London' 
'Heather' 'Female' 'Berlin' 

ちょうど正しい方向のポイントを探しています、ありがとうございます!これを取得する

+1

あなたはまだ何かを試してみましたか?いくつかのクエリを試してみて、なぜ結果が期待通りでないのかを教えてください。 – olibiaz

答えて

0

一つの方法:

$sql = SELECT count(*),R.restaurant //get the count and restaurant name 
FROM restaurants R, chefs C 
WHERE C.place_of_birth <> 'London' and //making sure place of birth is not london 
R.chef = C.name;//linking both tables by name(chef) 
0

また、このように問い合わせることができます:

select count(*) from restaurants 
INNER JOIN chefs ON restaurants.Chef = chefs.Name 
where restaurants.Location = 'London' AND chefs. Place_Of_Birth != 'London'