searching with LIKE |
[eluser]Peter Dräxler[/eluser]
Hi guys. PHP: Code: function like_find($keywords, $limit = 0, $offset = 0) SQL: Quote:SELECT `products`.*, `suppliers`.`Name` AS Supplier FROM (`products`, `suppliers`) WHERE `products`.`Supplier` = suppliers.Id AND `products`.`Code` LIKE '%text%' OR `products`.`PartNo` LIKE '%text%' OR `products`.`EAN` LIKE '%text%' OR `products`.`Name` LIKE '%text%' OR `products`.`Manufacturer` LIKE '%text%' ORDER BY `products`.`Price` ASC I want 1 line of every suitable product but it get 9 lines of every product :-( Please help! Thank's
[eluser]jmadsen[/eluser]
I think a DISTINCT might work better for him. GROUP BY is typically used when you want to use aggregates. It's not a correct way of eliminating duplicates, unless your query forces you into it for some reason.
[eluser]bretticus[/eluser]
True. I suppose it depends on how the tables are structured ultimately. Since we don't know...
[eluser]Peter Dräxler[/eluser]
Thank's for reply. Table products with sample data: http://dl.dropbox.com/u/1645785/products-table.png Table suppliers with actually data: http://dl.dropbox.com/u/1645785/suppliers-table.png I think, GROUP BY or DISTINC don't help me. I can have 2 records which will have different just Supplier and I want to view both. |
Welcome Guest, Not a member yet? Register Sign In |