943,972 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 665
  • MySQL RSS
Oct 11th, 2009
0

Mysql select tip

Expand Post »
Hai,

I had a mysql database and it contain columns like "id" and "name".

I am using the following query for selecting a name with an id .

My code is

$row=mysql_select("SELECT * FROM table where id='1'") or die(mysql_error());
$result=mysql_fetch_array($ROW);

$name=$result['name'];


It works and my problem is please let me know whether it is the easy way ? Or there is any other way to do this ?


Thanks in advance
Rajeesh
Similar Threads
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
rajeesh_rsn is offline Offline
265 posts
since Sep 2008
Oct 11th, 2009
0
Re: Mysql select tip
This is the way to do. If you need only name from the db, then simply use name in the SELECT statement instead of *.

php Syntax (Toggle Plain Text)
  1. $row=mysql_select("SELECT name FROM table where id='1'") or die(mysql_error());
Reputation Points: 29
Solved Threads: 47
Posting Whiz
mwasif is offline Offline
312 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: mysql query
Next Thread in MySQL Forum Timeline: MySql Service doesn't run





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC