Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

metin's avatar
Level 1

Limiting where query in laravel

database table name=dbtable column names of the table=gender,carName,city. I want to get 1000 data from the table. But 500 of the gender column will be female and 500 will be male. will get 300 honda, 200 jeep, 500 fiat from the car column And 100 Istanbul, 200 Paris, 200 Milan and 500 London from the city column. how can i do this in laravel sql query? thank you so much in advance

0 likes
5 replies
Snapey's avatar

its probably not possible since you have conflicting requirements.

If only women owned jeeps, and lived in paris, how could you satisfy the query?

metin's avatar
Level 1

@snapey The data that meet all the desired conditions are in the table

automica's avatar

@metin don't you want 500 women though?

if you queried for 500 women, and then you limited those results to the 200 that you want that owned jeeps, then your results would only return 200 women.

Snapey's avatar

Sounds like a homework exercise

automica's avatar

@metin your table doesn't allow for people who own multiple vehicles either.

Please or to participate in this conversation.