Skip to content
Advertisement

Tag: mysql

Wipe all tables in a schema – sequelize nodejs

To perform unit testing on a mysql database using sequelize as ORM, I need to refresh my database when each test start to run. Actually I wrote a solution like this: but every time I create tables I have to add another instruction. I would implement a single instruction to perform a complete wipe of the entire schema Something like:

How to split datetime 1 row into 2 or more rows based duration-mysql

How to split 1 row of datetime record into multiple rows by splitting duration based on datetime for every hour Input: Want to cut every hour by exact time by dividing duration Output: Answer You should try this query Here i have assumed that login and logout time have same date. it will give difference in minutes.

Nested queries in SQL

I am trying to combine 2 queries using a nested query. The first one is this: SELECT DISTINCT( de.MCH_CODE) AS Mach, md.MAT_CODE as ShortenCode, de.TIME as start_time FROM table1 AS de JOIN …

Adventure Works 2014 SQL Queries

I am writing a SQL query using Adventure Works 2014 database. I want to show all customers and how many orders each customers have. I tried to write each select statement by itself (see below), but I’d like to be able to combine both queries into one. Answer

sql query : show name with all vowels

Equatorial Guinea and Dominican Republic have all of the vowels (a, e, i, o, u) in the name. They don’t count because they have more than one word in the name. You can use the phrase name NOT LIKE ‘%a%’ to exclude characters from your results. The query shown misses countries like Bahamas and Belarus because they contain at least

Making dynamic SQL queries to a MySQL DB

I’ve never used golang with mysql before, so I’m reading about these for the first time. I’d like to do something like this: This is far too much typing, especially if I have a dozen more variables I’d like to add to the WHERE condition. If this were PHP, I’d do something like this: By using a foreach loop, I

SELECT query IF CONDITION

I have one problem with my SELECT query in my blog page. I want comment count of each blog when comment status=1. I am apply following query.. SELECT CONCAT(u.first_name,” “,u.last_name) name, r.*, …

Advertisement