I need help with a select statement that I’m currently struggling with. The scenario is this: select * from mytable WHERE isActive=1 and if only id is provided, select everything where the id=@id if firstname and lastname is provided, then select everything where firstname=@firstname and lastname=@lastn…
Tag: sql
Unable to import all values from google sheets to sql
I’m trying to import data from google sheets to mysql. I saved the google sheet as .csv. One of the columns square_feet has very few entries so there are a lot of blank cells. I am unable to import any row which has those blank cells. The error I’m getting is. #1366 – Incorrect integer value…
How can I select the max counted values from that was ‘GROUP BY’ twice?
Sorry for the bad title, I need to improve on how to explain my problem better, obviously. I’m practicing queries on the Adventure Works data in SQL server, and I queried such as: Which gives: And I’m trying to only get the largest count item, expected output looks like this: The max count for eac…
Copying data from rows in the same table if it meets multiple conditions
I have a table that looks this ID C1 C2 C3 C4 Date 101 1 1 1 1 01/01/2020 101 1 1 2 2 01/03/2020 101 1 2 3 01/05/2020 101 2 3 4 3 01/07/2020 201 1 1 1 1 02/02/2020 201 1 1 2 2 02/04/2020 201 1 2 3 02/06/2020 201 2 3 4 3 02/08/2020 What
Replacing certain characters of string in column (MySQL)
I have a table in a MySQL database that features a ‘name’ column with values such as: SDP3973455/1 101390375/2 SDP4608677 105859492/1 104295947 As you can see, some values have the characters ‘SPD’ in front and some values have ‘/1 or /2’ at the end of the string. I want to…
Filtering UNION ALL result is much slower than filtering each subquery
I have simple select that runs slowly. Exactly the same problem as in https://dba.stackexchange.com/questions/136653/filtering-union-all-result-is-much-slower-than-filtering-each-subquery I wonder is there anything I could do without making a function that accepts krepselis as parameter. There is my explain h…
ploting filtered results from clickhouse in grafana not working
I’m really new in grafana and clickhouse, I’m trying to do a filtered dashboard in grafana with information from some CSV logs loaded on clickhouse , this is how it looks the query on clickhouse: I want to plot that in grafana, my table name is logsb and using default db, column where looking matc…
Is that possible that access to a sql table with question mark?
I have 3 sql tables customer, employee and manager. I want to access dynamically to my tables. I had a statement like this, But in this situation i can only access to customer. I need to access all of the tables for different operations. Is that possible to write this, or what can i do to access for example e…
Convert array to implode value using ci
I have been getting value array and convert implode value comma separate ? Model: Controller: Array value: View json print value: Result: I need this value: Answer When there is only one field in the SELECT, an implode does nothing. You need to collect the data and then return the imploded data.
SQL- query processing-index nested loop join
when we are using Index nested loop join, is it index on joining column should be only for the inner table or it can be on the inner or outer table? Answer A nested loop join is looping through the outer table and then looking up a value in the inner table. The primary use of an index would be