Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 7th, 2012, 12:20 AM
Registered User
 
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
 
Old September 9th, 2012, 07:29 AM
Registered User
 
Join Date: Sep 2012
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What's the error you get from the DB?
 
Old September 10th, 2012, 06:13 AM
Friend of Wrox
 
Join Date: May 2011
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
 
Old September 10th, 2012, 11:02 AM
Registered User
 
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
 
Old September 10th, 2012, 11:15 AM
Registered User
 
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
 
Old September 11th, 2012, 07:13 AM
Friend of Wrox
 
Join Date: May 2011
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.
 
Old September 11th, 2012, 07:45 AM
Registered User
 
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 <>





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 04: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 07:01 AM
<STRONG> vs <B> and <EM> vs <I> anshul HTML Code Clinic 12 September 1st, 2004 05:22 PM
<<ASP.NET Security>>,download files in chapter 8 alaix All Other Wrox Books 1 July 24th, 2003 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.