mysql - SQL LIMIT returns no results where no LIMIT returns results -


select * mm_tfs  product_slug '%football%'      , schoolid = '8' , category_id ='21' limit 4 

returns 4 values i'm asking, following statement returns 0 - there rule using or statement i'm not familiar with? assumption should return of values in 1 (or more if weren't limit).

select * mm_tfs  (product_slug '%football%'     , schoolid = '8' , category_id ='21')  or (product_description '%football%'     , schoolid = '8' , category_id ='21')  limit 4 

note cyberkiwi first or portion of q2 same clause on q1

product_description '%football%' , schoolid = '8' , category_id ='21 

without or statement produce desired result long not have limit. when or statement used limit well, there 0 values returned.

select * mm_tfs  product_description '%football%'      , schoolid = '8' , category_id ='21' limit 4 

^-- produces 0 results

select * mm_tfs  product_description '%football%'      , schoolid = '8' , category_id ='21' 

^-- produces results

the strangest part of of these queries product right effect in phpmyadmin sql query window, not in application itself.

you repeating of conditions not necessary. try instead:

select * mm_tfs      (product_slug '%football%'   or product_description '%football%')    , schoolid = '8'     , category_id ='21' limit 4 

update:

i have created following table:

create table mm_tfs2 (schoolid varchar(2), categoryid varchar(2),                        description varchar(20), slug varchar(20)); 

and 5 times:

insert mm_tfs2 values (8, 21, '', 'football'); 

and query:

select * mm_tfs2  (slug '%football%' , schoolid = 8 , categoryid = 21)  or (description '%football%' , schoolid = 8 , categoryid = 21)  limit 4; +----------+------------+-------------+----------+ | schoolid | categoryid | description | slug     | +----------+------------+-------------+----------+ | 8        | 21         |             | football | | 8        | 21         |             | football | | 8        | 21         |             | football | | 8        | 21         |             | football | +----------+------------+-------------+----------+ 4 rows in set (0.00 sec) 

so i'm sorry i'm not able recreate problem.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -