bostboy — 2011-02-26T11:34:37-05:00 — #1
I have a situation where I want to present 10 records at a time for a like lookup but if there is a duplicate name, I only want to show it once and count as 1 in the 10 to be presented. To complicate it, the search is dependent on location so I can't consolidate the table prior to the selection.
So if I use the example of Burger King and I do a search in a large city, there will be numerous records in that city but I just want to show one when the like lookup is 'Burg%' so i would like to see Burger King, Burger Shack, etc. even though there are 35 records in the query for Burger King in that city.
bostboy — 2011-02-26T11:43:03-05:00 — #2
Never mind, it seems to work fine with
SELECT name FROM t1 where city = 'boston' and name like 'Chi%'
GROUP BY name limit 0,10
r937 — 2011-02-26T12:52:06-05:00 — #3
yes, that's a mysql enhancement to sql
GROUP BY name LIMIT 0,10
is equivalent to this --
GROUP BY name
ORDER BY name LIMIT 0,10
bostboy — 2011-02-26T14:29:38-05:00 — #4
Interesting, I had actually gone back and added the ORDER BY so I will now remove that. I really appreciate the input.