Results 1 to 6 of 6
-
8th Mar 2011, 01:33 PM #1OP
MySql Query
Consider there is the following table.
Now I want to query only the rows whose value is 1.
I use the following code
Code:$sql="SELCET name, reg, branch, year from i11 where sf='1'"; $result=mysql_query($sql); while ($row=mysql_fetch_array($result))
Code:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in \xampp\htdocs\reg\events.php on line 19
Kindly give information about the correct query.
Thank you.
GoPantheoN Reviewed by GoPantheoN on . MySql Query Consider there is the following table. http://lulzimg.com/i14/384165.jpg Now I want to query only the rows whose value is 1. I use the following code Rating: 5
-
8th Mar 2011, 01:42 PM #2MemberWebsite's:
florijan.netYou can check with the following if your mysql_query is being executed properly:
Error: you have SELCET instead SELECT
Code:$sql="SELCET name, reg, branch, year from i11 where sf='1'";
Code:$sql = "SELECT name, reg, branch, year FROM i11 WHERE sf='1'; ";
-
8th Mar 2011, 01:48 PM #3OP
Thank you for the correction
-
8th Mar 2011, 01:49 PM #4MemberWebsite's:
LulzCovers.com LulzTroll.comCode:$get=mysql_query("Select * from i11 where sf='1'"); while($result = mysql_fetch_assoc($get))
Contact me for Traffic, SEO, WCDDL, Wordpress, IPB related Services or queries.
Template Designing, PSD to HTML, Wordpress
-
8th Mar 2011, 02:06 PM #5MemberWebsite's:
florijan.net@deAthbLisS
Using * in a query is great to get all the fields, but MySQL tends to have better queries when you specify which fields do you need to get from the MySQL table.
If a MySQL table has 30 fields, and you need only 5 for your query, then selecting other 25 would be a huge overkill, as it would take more tie for MySQL to execute the query.
Specifying table fields that you need to select is part of MySQL best practice programming and it's good to stick to it even if you have 3 fields in you table.
Optimize where you can.
-
8th Mar 2011, 02:09 PM #6OP
Ya right, I need only selected fields to be quried up on the given condition.
Thank you death & ab1ko.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
PHP - MySQL query to CSV export
By ElitePirate in forum Web Development AreaReplies: 2Last Post: 25th Jul 2012, 09:19 PM -
mysql query to export database
By lenney in forum IP.BoardReplies: 4Last Post: 7th May 2011, 03:43 PM -
mysql query help ($5 reward)
By tdsii in forum Web Development AreaReplies: 20Last Post: 10th Jan 2011, 11:52 PM -
WordPress database error MySQL server has gone away for query
By blur88 in forum Webmaster DiscussionReplies: 10Last Post: 27th May 2010, 08:43 PM -
Speed Up Your Web Site With MySQL Query Caching
By BlaZe in forum Technical and Security TutorialsReplies: 1Last Post: 4th Nov 2009, 03:11 PM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...