Jump to content

Wildcards / Narrowing a SELECT query


davestewart

Recommended Posts

Hi there,

I've not come across this before, but is it possible to narrow a wildcard selection (as you can for example with regexp or file systems) such as these examples:

 

SELECT contact* FROM users

SELECT q* FROM survey

 

rather than

 

SELECT contact_email_1, contact_email_2, contact_address FROM users

SELECT q1, q2, q3, q4, q5, q6 FROM survey

 

Many thanks,

Dave

Link to comment
https://forums.phpfreaks.com/topic/87052-wildcards-narrowing-a-select-query/
Share on other sites

Not that i'm aware of. While mysql does have support for regular expressions and wildcards, they can, as far as i know, only be used in the context of the WHERE clause.

 

I would also be questioning your database structure if you have 6 fields named q1-q6. Perhaps its necessary, but it sounds like you need to take a look at database normalization.

Hi Ginger,

Thanks for the reply.

Yes, I know what you mean about the field names. In this case, it's OK, but I get that an 2-column intermediate table would in the main part be a better option.

It's a tiny site, and a fixed survey, so not worth the extra work in this case

:)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.