SQL quickie - any column in where clause?
#1
I need to seach all the columns in a table for a string. My code (simplified looks like):
SELECT * FROM products WHERE <columnname> LIKE '%memory%'
Is there a way of setting <columnname> to be any column in the table? Rather than having to do "productname LIKE '%memory%' OR prodcomment LIKE '%memory%' OR prodmfr LIKE..." etc?
SELECT * FROM products WHERE <columnname> LIKE '%memory%'
Is there a way of setting <columnname> to be any column in the table? Rather than having to do "productname LIKE '%memory%' OR prodcomment LIKE '%memory%' OR prodmfr LIKE..." etc?
#3
Assuming your using Oracle, doesent matter, pretty much the same whatever you use,
use PL/SQL or VB to output the columns as a text string and do a text search on the string, theres loads of ways to do it if you use a bit of code.
do a Select * from table where col1 LIKE %memory% or col2 like %memory% or col3 etc etc.
use PL/SQL or VB to output the columns as a text string and do a text search on the string, theres loads of ways to do it if you use a bit of code.
do a Select * from table where col1 LIKE %memory% or col2 like %memory% or col3 etc etc.
#4
Cheers for the help guys.
I'm using MySQL. I've done it in the code now. I was trying to be clever and make it so the search would include any new colums added to the table without having to modify the code.
I'm using MySQL. I've done it in the code now. I was trying to be clever and make it so the search would include any new colums added to the table without having to modify the code.
Thread
Thread Starter
Forum
Replies
Last Post
Mkhan
Non Scooby Related
14
09 August 2001 02:07 AM