Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Fri Apr 20, 2007 3:57 am
Code: Select all
SELECT DISTINCT product
FROM scheme.opservm
WHERE product LIKE 'A%'
OR product LIKE 'B%'
OR product LIKE 'C%'
OR product LIKE 'D%'
OR product LIKE 'E%'
Regards,
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Fri Apr 20, 2007 4:03 am
It's less code, and it works, but I'm not sure it's really a good idea:
Code: Select all
SELECT DISTINCT `product` FROM `scheme.opservm` WHERE LEFT(`product`,1) IN ('A','B','C','D','E');
I'd definitely try benchmarking it because it might well be a lot slower.
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Fri Apr 20, 2007 4:15 am
Is there a tool for MySQL benchmarking or is just the case of comparing the "Query took x" time for each query?
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Fri Apr 20, 2007 4:45 am
Also,
Is it possible to use the BETWEEN syntax on letters.
E.G:
Code: Select all
SELECT DISTINCT product
FROM scheme.opservm
WHERE LEFT (product, 1) BETWEEN ('A' AND 'Z')
I realise that query doesn't work but I'm just trying to make my question clearer.
Regards,
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Fri Apr 20, 2007 5:03 am
Yes, you can do that. Remove the brackets after BETWEEN.