Copy link to clipboard
Copied
Hello, I am designing my first Dynamic Website in PHP and WAMP and have so far managed to create a working Search Element on my website (search for 20mm on www.reese-test.co.uk )
It shows a linkable pic in "column 1" and Description in "column 2".
What I would ideally like though is to seperate the code and description columns (as shown below - pic 1), the problem is the search only works by finding the content in the description column, I have tried all different things in the "Advanced" tab to Filter by "Code" and "Description" but it is still only filtering by "Description" only.
My question is, does anyone have any simple instructions to get it to filter for both columns. In the "Simple" panel I can only select one option to filter!!!
thankyou for your help!
>I have tried all different things in the "Advanced" tab to Filter by "Code" and "Description"
To write SQL queries you need to understand Boolean logic. You can't use AND because that would mean that both conditions would need to be true. You want results if either condition is true, so use OR.
Select *
FROM productlist
WHERE description LIKE %colname%
OR
code LIKE %colname%
ORDER BY code ASC
Copy link to clipboard
Copied
>I have tried all different things in the "Advanced" tab to Filter by "Code" and "Description"
To write SQL queries you need to understand Boolean logic. You can't use AND because that would mean that both conditions would need to be true. You want results if either condition is true, so use OR.
Select *
FROM productlist
WHERE description LIKE %colname%
OR
code LIKE %colname%
ORDER BY code ASC
Copy link to clipboard
Copied
. . .also, LIKE is a rinkydink search method. Better to use MATCH. . .AGAINST.
Copy link to clipboard
Copied
thankyou BREGENT. that worked although to get it working, I had to lay it out like:
SELECT *
FROM productslist
WHERE `description` LIKE %colname% OR `code` LIKE %colname%
ORDER BY code ASC
Rob: I cant see what i should change, do you mean something like: (appologies - first time i've done this!)
SELECT * MATCH `description` AGAINST `code`
FROM productslist
WHERE `description` LIKE %colname% OR `code` LIKE %colname%
ORDER BY code ASC