Skip to content

Tag: mysql

How to store tags for a blog article in SQL database?

I currently am working on developing a blogging website. For this application we’re using MySQL as the database. For this application,I created a blog table which contains the following properties: id blog_title content user_id updated_at upvotes I want to add tags to this table. What is the recommended…

Symmetric Pair in SQL with JOIN

I am trying to find the name of students where a symmetric pair exists. There are 3 tables: Edit from your comment: A student is called as being a part of a symmetric pair if the marks obtained by that student in science is equal to the marks obtained by some other student in mathematics and the marks obtaine…

select starting digitals followed by first word in mysql

I have lots of addresses in my database. example: 1199 State Route 218 I want to select the starting digitals followed by first word and ignore the rest of the address. so i want to retrieve address just by calling this: 1199 State thanks for you help Answer If you are running MySQL 8.0, you can use regexp_su…

Generate series of random size data in MySQL

I need to populate table with random size of data for each dependency record. First table is table of products (named products): And the second table is table that contains displays of that product (named product_displays). Each display is another row: Like you can see date will always be the same value, but …

Select the last record in MySQL in WHERE condition

I have a table that store ticket and statue relation I want to select rows that last status_Id equal 2 ,Rows are marked in table. I think I have to use GROUP BY on column ticket_Id but it return with first status_Id. Answer This problem is a good candidate for ROW_NUMBER: The above logic finds all latest rows…

Filter duplicate records and retain 1 record

I was able to get the duplicate records and I wanted to retain 1 record per item barcode based on the createdate (oldest) sample script of getting the duplicate records: output: final output should be like this: (retain the items that has the oldest createdate from the 2 duplicate Barcodes) Answer I guess you…