MySQL SELECT rows which respond to specific MULTIPLE values in one of the columns -
i've looked on web, , in stackoverflow well, , have found many similar topics, none answers needs. i'm sending out there, knowing there's little thing i'm missing in order work.
let's imagine following table:
location | title | description | quantity ============|===========|=============|========== shelf | apple | red | 2 drawer | banana | yellow | 4 shelf | kiwi | green | 2 cupboard | lemon | yellow | 1 fridge | melon | orange | 3 drawer | peach | orange | 1 what want select table items either in drawer or on shelf (so drawer , shelf) , order them by, example, first, location ascending and, second, quantity descending.
so have (after searching on web) following code, 1 doesn't return error, but doesn't return items either:
select * items location = 'shelf' , location = 'drawer' order location asc, quantity desc
where going wrong? feedback appreciated!
usually questions go toward how select values multiple tables , join them. however, need values 1 table; however, these values need respond specific multiple values share.
select * items location = 'shelf' or location = 'drawer' order location asc, quantity desc or
select * items location in ('shelf','drawer') order location asc, quantity desc although 2 items, i'd go first myself, 3 or more, might use in()
additional info: reason why getting no records returned because using and in condition. remember there 1 , 1 value every column in row.
Comments
Post a Comment