You have to use side effecting variables for this
SELECT profilename, name
FROM
(
SELECT m.profilename, s.name,
@r:=case when @g=m.profilename then @r+1 else 1 end r,
@g:=m.profilename
FROM (select @g:=null,@r:=0) n
cross join menus m
left join menuitems s on m.menuid = s.menuid
) X
WHERE r <= 5
Related Contents:
- How to SELECT the newest four items per category?
- SQL: Find the max record per group [duplicate]
- Selecting all corresponding fields using MAX and GROUP BY
- Get top 1 row of each group
- How can I do a FULL OUTER JOIN in MySQL?
- Get top n records for each group of grouped results
- You can’t specify target table for update in FROM clause
- How to use GROUP BY to concatenate strings in MySQL?
- Auto Increment after delete in MySQL
- SQL join: selecting the last records in a one-to-many relationship
- Best way to test if a row exists in a MySQL table
- MySQL Insert query doesn’t work with WHERE clause
- Comparing date ranges
- In MySQL queries, why use join instead of where?
- how do I query sql for a latest record date for each user
- Oracle SQL query: Retrieve latest values per group based on time [duplicate]
- SQLite INSERT – ON DUPLICATE KEY UPDATE (UPSERT)
- MIN/MAX vs ORDER BY and LIMIT
- MySQL “NOT IN” query
- MySQL number of items within “in clause”
- MySQL unknown column in ON clause
- Fulltext Search with InnoDB
- Alter a MySQL column to be AUTO_INCREMENT
- MySQL not using indexes with WHERE IN clause?
- MySQL ON DUPLICATE KEY UPDATE for multiple rows insert in single query
- single fixed table with multiple columns vs flexible abstract tables
- mySQL :: insert into table, data from another table?
- Return 0 if field is null in MySQL
- MySQL “between” clause not inclusive?
- How to search multiple columns in MySQL?
- mysql, iterate through column names
- Rewriting mysql select to reduce time and writing tmp to disk
- How do I convert from BLOB to TEXT in MySQL?
- MySQL – how to front pad zip code with “0”?
- MySQL: Transactions vs Locking Tables
- MySQL: What is a reverse version of LIKE?
- SQL server select distinct rows using most recent value only
- SELECT query return 1 row from each group
- How to delete Duplicates in MySQL table
- Multiple Ranks in one table
- How to create a multi-tenant database with shared table structures?
- How to select the most recent set of dated records from a mysql table
- MySQL GROUP BY behavior
- MySQL #1140 – Mixing of GROUP columns
- Any way to achieve fulltext-like search on InnoDB
- Adding a new SQL column with a default value
- Boolean vs tinyint(1) for boolean values in MySQL
- Is it possible to have a default parameter for a mysql stored procedure?
- ALTER TABLE without locking the table?
- MySQL: Compare differences between two tables