Jump to content

Only pull certain data from sql.


marketboy

Recommended Posts

I need to be able to pull only certain fields from my database.  Instead of pulling all data from field "x" I need to pull or exclude data to certain items. 

 

$sqlDealers="SELECT id, CONCAT(first_name,' ',last_name) AS name FROM ".$db_prefix."dealers ORDER BY name";

$rsDealers=@mysql_query($sqlDealers) or trigger_error('Error on executing '.$sqlDealers, E_USER_ERROR);

 

 

It's selecting the id field, but I need to either make it show only some of the items, or exclude others.  Any input would be apreciated!

Link to comment
https://forums.phpfreaks.com/topic/87825-only-pull-certain-data-from-sql/
Share on other sites

Ok, I've tried a variation of ways, but keep getting a fatal error:

 

Fatal error: Error on executing SELECT id, WHERE id='33' CONCAT(first_name,' ',last_name) AS name FROM free_listings_dealers ORDER BY name in /home/content/m/a/r/marketmy1/html/index1-15.php on line 55

 

I changed the code to this:

 

$sqlDealers="SELECT id, WHERE id='33' CONCAT(first_name,' ',last_name) AS name FROM ".$db_prefix."dealers ORDER BY name";

$rsDealers=@mysql_query($sqlDealers) or trigger_error('Error on executing '.$sqlDealers, E_USER_ERROR);

 

 

Anything?

Ok, great.  Thanks!  I thought I had done that at one point, but I had a misplaced quote. 

 

One last question now, would be if I wanted to include/exclude more than one variable? For example, if I wanted to include both id number 33 and 34.

 

Thanks again!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.