Skip to content

Tag: sql

mysql update with if and max

I have lost hours on this and nothing works for me. I have filed strp_aa that is default NULL. The filed strp_aa should update only if its null with MAX strp_aa + 1, and if its not null if it already has a number it should stay the same. short version of code is Also tired I tried multiple things

SQL query 2 limits

I have the following issue i want to limit on the total amount of items returned while limiting one value to a certain number I do a query like this Now I want to do the following, I have a field called running and I want to be able to say that in these results I want to have maximum

SQL turning rows into columns and populating with values

I’m not quite sure why this table was designed this way, but it’s making it hard to solve my problem. Looking at the data: What I need help with is to do the following: For each name have the type_name as a column and then fill those columns with the default_value or value. Like this: Basically po…

The Delete code doesnt work after it updates a column

When I send data to the procedure which contains the ResStatus as C it updates the ResMaster’s ResStatus as X After it updates the column, I want to delete a record from 2 tables they are- Folio,ResRoomAllocation. I have done the coding but it doesn’t work it only updates the ResStatus as X What&#…

Sort a table but keep groups of rows together

How do I sort a table by it’s minimum value per group but at the same time keep a group of rows together. Below a simple example of what i am trying to accomplish. The table is sorted by the lowest group value, but the group remains together. I am pretty sure this question has been asked already but i