Skip to content

Tag: sql

Doing a WHERE .. IN subquery in Doctrine 2

I’d like to select order items from all orders with a specific item. In SQL I’d do it like this: How would I do this query with the query builder? Answer This is how I would try it: I didn’t test this of course, and made some assumptions about your models. Possible problems: Limit: this has …

How to add minutes to datetime?

I want to add minutes that already exist in same table. I have a datetime and a duration. I want to get the start date/time as well as the end date/time. I can use datetime but have to specify ‘localtime’ which doesn’t work. I want the equivalent of DATEADD in SQL Server. Answer Try start_da…

How to write condition wise result providing query?

I want to write a MySQL query that gives a condition wise result. For example. I have a table with question, answer value, user chose value fields. User can attend to answer that question many times. qid rightanz wronganz 11 4 2 11 4 4 11 4 1 25 1 1 I want out put like this qid rightanz wronganz