tags:

views:

37

answers:

2

Hello.

I have pretty big table with lots of columns. I want to find all lines, with some word in it.

Sure, i can write something like

SELECT * FROM table WHERE 'blablabla' IN col1 OR 'blablabla' IN col2 OR ...

But I think it's not the best solution =))

UPD Of course, it's bad database design, I know it. =) I did not created that table, i've just have to parse some values from it. ;)

A: 

I don't think there is a better solution. Databases are designed for organized data and they don't suppose you will be searching across all rows.

You can concatenate that query in your programming language with automatic field names detection, but it really look like bad database design.

praksant
Well, I agree with you, but I just don't have a choice =)
Alright, then your option is to get column names with query:SHOW COLUMNS FROM table, and with a loop make that long query automatically
praksant
A: 

Hitting this issue indicates that there's a chance that the schema is flawed, usually that it's not in 1NF.

Ignacio Vazquez-Abrams