I have this query which is rather slow for my liking : Explain analyse output Is there an index I can put on to speed this up (bearing in mind that the values for the order by will be dynamic)? I was thinking a partial index on where bust,figure,age,hair ethnicity is not null and status = ‘online’…
Tag: sql
Problems with SQL query. Select row with max() column
You need to get the username or usernames with the maximum number of integrations. ER Diagramsenter image description here Try One: SELECT username FROM (SELECT au.username, COUNT(DISTINCT ci….
Update SQL table using C#
I’m trying to update EpisodeId no:117 in the Episode table and it executes successfully but when I check the table it is not updated. int episode Id = 117; Answer There are some issues with your SQL update statement.Look at following for reference to Update Statement in SQL LINK There is also an easier …
Best approach to ocurrences of ids on a table and all elements in another table
Well, the query I need is simple, and maybe is in another question, but there is a performance thing in what I need, so: I have a table of users with 10.000 rows, the table contains id, email and more …
join of two queries missing values
I need help joining these two queries. Here’s the first dataset with its query: : and second: : My query produces this result: I need to return as I can’t figure out why my query is leaving out the records with no Inbound data. I believe a right join is correct. It seems like an issue with using t…
mysql count from table where related record exist in other table
I have 2 tables, customers and addresses. I want to count how many customers have addresses with name like a given search term something like SELECT COUNT(*) as countSearch FROM customers,addresses …
While updating table1, how do I INSERT to table2 for every change in table 1?
I have a MEMBER table and NOTIFICATION table. On client side, I list all of the records in MEMBER table and there is a points column and this is shown as text input. So after I change the values for some members, I can click save button and this will update the records in my MEMBER table that’s all righ…
Mysql When then and temp variable. Explanation
I have this sql query that I am trying to understand. Can I get a line by line explanation please. I know the first line Initialise variable. Second line gets the minimum value. Answer The variables are enumerating the rows for each occupation separately. You can see this by running the subquery to see the re…
Return a 0 if no rows are found in Microsoft SQL Server
I need your help with this query. My table CSO_EMP_ORG_DPM_VIE has a column with different keys. Column name is EXT_KEY. When I receive the same key number in EXT_KEY, I want the SQL code to count the duplicates using this query: This is working so far, but when it has no duplicate keys (numbers) in the colum…
How to avoid & popup when SQL query contain ‘&’ letter?
I am writing a migration script where I replaced html encoded values by original values like & will get replaced by &. So my SQL query has & letter but when I execute this query it give me popup for every & to replace that character which is as shown below After clicking on OK its giving a…