Let’s say I have a table Songs(title,songwriter). I want to get a list of songs where songs of the same songwriter appear in one block. So i just sorted: SELECT * FROM Songs ORDER BY songwriter ASC …
Tag: database
use select statement in default while declaring a table
I want to set a default value to a column while declaring a table , but the value is not constant , actually it’s based on some other data from another table . I’m interested to know if there is such …
Disable trigger in another db(Oracle)
Can I create a procedure that disables a trigger in another database? I mean, can I disable it with a database link? I need it for importing data into a data warehouse
Split a string into two fields based on multiple words
I have the following column in my Table name:STAT It would be helpful if someone can assist in writing a mysql script I would like to split the strings in to 2 columns. However the split should happen only based on the last word, i.e the Region as can be seen in the example below. There is an exception that
Converting multiple rows into one row by ID
What I am trying to achieve is group them by id and create a column for the date as well as data. The background of the dataset are it is lab result taken by participant and some test are not able to …
SQL refer Primary Key in same Table and Query
I am maintaining a table of Items (Id is Primary Key). Some Items have Parent Item ( Which is also an Item, the colum Parent holds the Id of the parent Item, which is also in the same table. Some …
how to compute percentage in mysql/sql when 2 group by conditions are present
id title count organizer 1 music 4 2 2 sports 6 2 3 music 2 3 I have a derived table with the above structure. I need to compute the percentage of the number of events of each …
How to update a database table letting two fields be empty/not filled/null
On a blog I’m coding I want admins to be able to edit a comment. This works just fine, but there’s a problem with writing a new comment because of two fields in the table that should be empty then. …
Value referenced by NEW on an unchanged column in an UPDATE trigger
I have a table Group_Members with a DELETE trigger and an UPDATE trigger. The DELETE trigger updates some rows in A hence invoking the UPDATE trigger. Here’s the DELETE trigger code: UPDATE …
Nested Assemblies Database Structure
I’m creating quoting software for the manufacturing business I work for and I’m unsure how to handle assemblies within my MySQL database structure as they are a little like a Russian Doll. Here’s a …