Skip to content
Advertisement

Tag: sql

Filter a case in a where clause

I want to filter on a case statement in my where clause for example: Select name, address, case when code in (50000-8113, 512388-8114) then ‘M345’ else ‘N/A’ end as Mucode Where mucode = ‘…

MERGE Statement is not working in Informix v10

I tried to use the merge statement to Insert/Update in Informix v10.0 but it throws a Syntax Error: Could you please help? Answer The MERGE statement was not available in Informix 10.00. It was added in 11.50 — see the MERGE statement in the SQL syntax manual. The new features page suggests it was added in 11.50.xC6, part of the

MySQL GROUP BY slows down query x1000 times

I’m struggling with setting up proper, effective index for my Django application which uses MySQL database. The problem is about article table which for now has a little more than 1 million rows and querying isn’t as fast as we want. Article table structure looks more or less like below: After many tries I came that below index gives best

Eloquent hasMany doesn’t load collection

I’m relatively new to eloquent, and have problems loading data from a hasMany relation in an app that uses eloquent as the database layer. My (simplified) code is as follows: The SQL Schema is like below I then do the following query: This results in a json like the following Raw SQL query shows me that I do have data

Arabic text in sp_sqlexec insert return question mark

Records are imported into table #FileRecords and ##TableInsert are dynamic tables, it can be table A, table B(which justify the reason of using exec sp_sqlexec). When Arabic wording going through sp_sqlexec, it will insert ??? instead of the Arabic wording. Is there anything I am not aware of, beside of encoding and N in front of the string? Output: Above

Use multiple but identical aggregate function

I’m trying to use two identical aggregate function is SQL Server, where I use COUNT(A) with some condition and COUNT(A) with another condition. For example I want to count all students enrolled in the course ABC, and the second count I want to count all students who have grade A and have enrolled in the same course ABC. But the

Advertisement