Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 7th, 2012, 01:20 AM
Registered User
Points: 39, Level: 1
Points: 39, Level: 1 Points: 39, Level: 1 Points: 39, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 9
Thanks: 4
Thanked 0 Times in 0 Posts
Default How can I use operators(!=, < , > etc) for checking

Dear Sir,

I tried to use operators(!=, < , > etc) for finding data from database using this query

"SELECT `id`, `name`, `thumbnail`, `category_id` FROM (`products`) WHERE `status` = 'active' AND `id` `!=` '6' ORDER BY `category_id` desc LIMIT 100", but found error message.

Can you please suggest me how can I fix this problem ?

Thanks
Jobayer
Reply With Quote
  #2 (permalink)  
Old September 9th, 2012, 08:29 AM
Registered User
Points: 55, Level: 1
Points: 55, Level: 1 Points: 55, Level: 1 Points: 55, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What's the error you get from the DB?
Reply With Quote
  #3 (permalink)  
Old September 10th, 2012, 07:13 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Quote:
Originally Posted by plavalle View Post
What's the error you get from the DB?
See here: Getting error message while trying to checking field using operators in active field
Reply With Quote
  #4 (permalink)  
Old September 10th, 2012, 12:02 PM
Registered User
Points: 39, Level: 1
Points: 39, Level: 1 Points: 39, Level: 1 Points: 39, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 9
Thanks: 4
Thanked 0 Times in 0 Posts
Default

It shows "Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`!=` '6' ORDER BY `category_id` desc LIMIT 100' at line 4

SELECT `id`, `name`, `thumbnail`, `category_id` FROM (`products`) WHERE `status` = 'active' AND `id` `!=` '6' ORDER BY `category_id` desc LIMIT 100".

Thanks in Advance
Jobayer
Reply With Quote
  #5 (permalink)  
Old September 10th, 2012, 12:15 PM
Registered User
Points: 55, Level: 1
Points: 55, Level: 1 Points: 55, Level: 1 Points: 55, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
Default Try this

Code:
SELECT `id`, `name`, `thumbnail`, `category_id` FROM (`products`) WHERE `status` = 'active' AND `id` != '6' ORDER BY `category_id` desc LIMIT 100
Reply With Quote
  #6 (permalink)  
Old September 11th, 2012, 08:13 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

You're missing the point in the topic I mentioned above the OP says this;
Quote:
Originally Posted by jobayer_34 View Post
Dear Sir,

Thanks for your message. I have used db->where('id !=', '6') then it produces this query. Can you please suggest me how can I use operators for checking (I want to check where id!=6)?

Thanks in advance
Jobayer
so he's using the class method 'where' to generate the WHERE clause BUT it's wrapping the != in back ticks/quotes so it's generating an error when the sql is executed.
Reply With Quote
  #7 (permalink)  
Old September 11th, 2012, 08:45 AM
Registered User
Points: 55, Level: 1
Points: 55, Level: 1 Points: 55, Level: 1 Points: 55, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
Originally Posted by UseLess View Post
Greetings,

You're missing the point in the topic I mentioned above the OP says this;


so he's using the class method 'where' to generate the WHERE clause BUT it's wrapping the != in back ticks/quotes so it's generating an error when the sql is executed.
Yep, I missed that other post ...

I responded there. NOT EQUAL operators are either != or <>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 05:37 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 08:01 AM
<STRONG> vs <B> and <EM> vs <I> anshul HTML Code Clinic 12 September 1st, 2004 06:22 PM
<<ASP.NET Security>>,download files in chapter 8 alaix All Other Wrox Books 1 July 24th, 2003 11:29 AM



All times are GMT -4. The time now is 11:29 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.