CE

May I ask you a database search question, please? I am useless with databases but I know how to search for one item at a time in my website's database; I just put in the item code (e.g. wk660) on the pd_code field line in the phpMyAdmin search page, but I don't know how to search for more than one item in a single search.

I want to search for several items in one search, using more than one item code at a time. I tried... wk660 OR wk30 OR wk483 to search for three at the same time for the field but it didn't find anything, although all three can be found if I do them one at a time.

I also tried separating them with AND and I tried enclosing the product codes in %%. None worked. My Google searches haven't helped me find how to do it. Can you tell me what I should put in to search for several items in one search, please?

There is a screenshot below of the phpMyAdmin search page to show what I mean. The line I put the item code (what I am searching) into is the pd_code field, you can see one item code in it in the picture:

phpMyAdmin Search Database Table

add a comment
0

2 Answers

  • Votes
  • Oldest
  • Latest
BW

From the pulldown menu instead of choosing LIKE, choose REGEXP. Then for the value separate each thing you are searching for with a pipe symbol, which is |. So for instance you would put this for the value in the phpMyAdmin field box for pd_code:

wk660|wk30|wk483

Let me know if that does the trick 🙂

  • 0
    Yay! It found and displayed all three I put in. Thank you — cerio
add a comment
0
JO

You can also use raw SQL to easily to do what you want, even in phpMyAdmin:

SELECT * FROM tbl_product WHERE pd_code IN ( 'Value1', 'Value2', ... );
add a comment
0