Skip to content

How to check the query is using the indexes in mysql

I have a SQL query with where clause, I have created the index for the columns which are being used in the where clause. How can I check the query is using the indexes for these columns? Answer Write “explain ” in front of your query. The result will tell you which indexes might be used. For examp…

BigQuery GROUP_CONCAT and ORDER BY

I am currently using BigQuery and GROUP_CONCAT which works perfectly fine. However, when I try to add a ORDER BY clause to the GROUP_CONCAT statement like I would do in SQL, I receive an error. So e….

C# sql create one connection and open and close for each query

I recently inherited a C# Web app that creates a new connection for every query like so: I understand that this is typically the best way to do it, but is it acceptable or “best practice” to have the constructor create the connection object, and then have each method/Query open and then close that…

Find out available days and slots for doctor appointment

I have three tables: TimeSlotToken is the number of patients a doctor will see in his TimeSlot. TimeSlot 1, 2, and 3 are Morning, Afternoon and Evening respectively. I need to find the days where the TimeSlot is not full, i.e TimeSlot token is less than total bookings on that particular day and that slot. Sin…

How to retrieve count of records in SELECT statement

I am trying to retrieve the right count of records to mitigate an issue I am having. The below query returns 327 records from my database: Where I run into trouble is trying to reconcile that with the below query. One is for showing just a count of all the particular students the other is showing pertinent in…

Connect to SQLite3 server using PyODBC, Python

I’m trying to test a class that loads data from an SQL server given a query. To do this, I was instructed to use sqlite3. Now, the problem is that while the class manages to connect to the real …