Jump to content

stupid query


otuatail

Recommended Posts

cant get simple query to return anything. The querry when used in mysql via phpmyadmin returns 276

 

$sqlhits = "select count(EventID) FROM EventLog AS Count WHERE Hit = 'Y'";

$rsHits = mysql_query($sqlhits);

$Item = mysql_fetch_array($rsHits);

echo $Item['Count'];

 

retuns blank

 

Link to comment
Share on other sites

you can use an alias for any column name but depends where you put it. you put Count in your FROM clause so you are giving the alias to your table not your column. If you had 2 tables with the same column name your query would fail. In phpmyadmin it should actually show count(Eventid) so if you wanted to return it in php it would be

$Item['count(Eventid)']

 

All aliases for column names should be in the SELECT clause.

 

Ray

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.