Skip to content

Tag: mysql

MySQL select based on earlier row’s data (audit table)

I have an audit table that is structured as follows: This table is tracking whether we were able to successfully source a particular data point for a customer. Sometimes we are able to find the data on the first attempt, and you know this because there was no entry with a status of failed, the first occurrenc…

MySQL COUNT and IFNULL

I have tables like this: SQLFIDDLE I’m trying to count how many products are in each category SELECT `category_id`, `category_name`, IFNULL(count(*),0) cat_stat FROM `product_to_categories` …

Get all values from intermediate table

I have a mySQL three-table many-to-many setup with link table, simplified here: categories category_id category_name categories2entries category_id, entry_id entries entry_id entry_text …

I am missing an alias for a derived table

I know, this question has been asked very often but I know my error, I know how I could fix it, but I can´t find the point where the error is. In my opinion, all the subqueries have different and …