开发者

SQL query giving error?

$bilgi= mysql_query("SELECT age,wname,slid,sex FROM user AND city WHERE user.ci_name=(SELECT ci_id FROM city WHERE ci_name='$ciname')");
while($sutun= mysql_fetch_array($bilgi))

This is my statement of query. This gives me error and the error is supplied argument is not valid MySQL result in resource in ....

Now let me explain what I am doing. I am sending some ci开发者_Go百科ty name to my database in order to find the unique number of the city. I send Istanbul and it's id is 2 in my database. I have 2 tables, 1 is city the other one is user. User table has age,wname,sex,slid; and ci_name part that is foreign key with the city_id. city_id is the primary key of the city table. I want to find the age, wname, slid and sex of Istanbul.

Can anyone help me how can I get throw with this error and find what I want :)?


$bilgi= mysql_query("SELECT age,wname,slid,sex FROM user, city WHERE user.ci_name=(SELECT ci_id FROM city WHERE ci_name='$ciname')");
    while($sutun= mysql_fetch_array($bilgi))

You had an AND in your FROM section, which isn't valid.


You can use one Query instead of using two like you:

$query = 'SELECT age,wname,slid,sex FROM user, city WHERE user.ci_name = city.ci_id AND city.name = '".$yourCityNameYouSeek."'';

The only thing I don't get is which table-column your city name is stored. In user-table you have ci_name (is that a NAME or an ID)?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜