Re: problem....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, your query looked confusing to me, but break it up like this

First :
    select
Then, name your coloumns, seperate with commas, or use wildcard for all
    *
Define from what table you need to select
    FROM database_table
Add some select statements with WHERE
    WHERE
and the statements itself
    1=1

What did I just write now? Looking at your example I guess :
1. you need the coloumns : Rune, username
2. your table : RuneRunner
3. your select criteria : UserID=3

I would then write your SQL query as this :

$sql = "SELECT Rune, username FROM RuneRunner WHERE UserID=3";

Then you could do your code,
$pic = mysql_query($sql,$connection);
$pic = mysql_fetch_array($pic);

You would also want to add a database abstraction layer, as for debugging
purposes this will make your life much easier.

Your original code looks to correct if you rewrite it abit, like this :

SELECT RuneRunner_1.Rune, RuneRunner_1.username FROM RuneRunner RuneRunner_1
WHERE (RuneRunner_1.User_ID=3);

Not tested but it should work fine. On the other hand, the referencename
after the
table name should be a short one to make the statement much easier to read,
somthing like :

SELECT rr.Rune, rr.username FROM RuneRunner rr WHERE (rr.User_ID=3);

Then again, since you only have one table in your statement there is no need
for the reference name,
and since your WHERE clause is a single statement there is no need for the
paranthese either.
So you are still back to :

SELECT Rune, username FROM RuneRunner WHERE User_ID=3;

--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------

"Water_foul" <phpdbnews@xxxxxxxxxxxxxxxxxxx> wrote in message
news:20040623000943.72840.qmail@xxxxxxxxxxxxxxx
> why doesn't this work:
> $pic=mysql_query('SELECT     Rune, username FROM         RuneRunner
> RuneRunner_1 WHERE     (User_ID = 3)',$connection);
> $pic=mysql_fetch_array($pic);

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux