Skip to content

Tag: mariadb

Show specific rows in SQL by not existing in another table

I’m not very experienced in advanced SQL and stackoverflow, so I’m trying my best to explain what I need. Let’s say I have a table called ‘Shift’ and a table called ‘Schedule’. ‘Shift’ has columns ‘shift_id, shift_start, shift_end, shift_day, shift_f…

Ranking subcategories while keeping order of ID

I have the following table: I would like to rank the subcategory (cat2). Desired outcome: I use DENSE_RANK with PARTITION BY to get the following result: Statement: As you can see, the only thing I’m missing is the order of the result. Currently, the rank is based on the alphabetic order of cat2. Howeve…

Query table using multiple foreign keys

So I’m just messing around with a NodeJS application, and I’m trying to implement a permission system using my database. It’s my first time working with any kind of SQL environment, so please correct me if I’m doing something terribly wrong. I have the following tables: So there are 2 …

MariaDB : an INSERT…SELECT with empty VALUES too

I want insert data from another incomplete table, so some values must be empty in NOT NULL fields. For example, I have two tables : people and peopleTemp. In people table, I have a lot of fields : permit_number, first_name, last_name, gender, tel, etc. In peopleTemp table, I have only permit_number, first_nam…

How to select count between start to (start+length) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question How the following result appears when creating a table as above. This is the result of count…

I want to fetch 2 records with same id

This is my user table and i want to fetch 2 rows in descending using user_id. I want output like. Thanks in advance Answer I think you strictly need an ANCIer approach. You should try below co-related sub query – Fiddle.

Creat procedure in mysql

I was learning sql from w3schools.Here is given simple mysql procedure but somehow I couldn’t to write down this procedure I’m new in sql please could you provide me with feedback. DELIMITER // …