Skip to content
Advertisement

Tag: mysql

How to get a COUNT() value when GROUP BY has no row?

RDMS : MariaDB 10.1.23 MCRE : SQLFiddle: http://sqlfiddle.com/#!9/f32a01/1 Consider the following query : Without the GROUP BY clause, I know that COUNT() will return 0 if no row match the query. I also know that, if my GROUP BY “fails” (If i have no row to group by, in my example, if no row satisfy e.created_at > CURRENT_DATE – INTERVAL

How do I update if exist, else insert in MySQL

I have table with AUTO_INCREMENT field defined as PRIMARY_KEY. I have columns like: vote_id,vote_user_id,vote_ask_id,vote_comment_id,vote_post_id,vote_type,vote_status I want to INSERT new records but before I do that I want to check if there is a row with columns(vote_user_id,vote_ask_id,vote_type) as same as the new data I want INSERT. I have searched the internet and learnt about MySQL ..ON DUPLICATE KEY UPDATE. I have

Multi-parameter search with mysql and node.js

Let me preface by saying I’m very new to SQL (and back end design) in general. So for those annoyed with noob questions, please be gentle. BACKGROUND: I’m trying to build a product test database (storing test data for all our products) where I want a user to be able to refine a search to find test data they actually

Mysql Group By age by range [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 i need help, i need to create report like this the report is group by the age, but i can’t get when age under <=

Prioritize one column over another

DB-Fiddle In the table above I have different campaigns with their corresponding quantities. The quantities are filled in different columns. Now, I want to get the latest available quantity for each campaign based on the following hierarchy: The result should look like this: What query do I need to achieve this? Answer Use coalesce():

Advertisement