Skip to content
Advertisement

Tag: mariadb

How to make a SQL query partial match with substrings not in the beginning

Let’s say there is a column called: m_report_notation Said column, has values such as: NM_004004.5:c.235del (p.L79Cfs*3) And I would like that, if the value of v is, for example: 235del, then get NM_004004.5:c.235del (p.L79Cfs*3) as a result. This is my current query and what I’ve tried so far (using MariaDB connector for Django): If for example, v = NM_00 I

Iterate through query

I’m trying to iterate through simple query This is what I managed to create But I get: Answer You don’t need a while loop for this. You can do this in a single query. One method is: Trying to use a while look is troublesome. Such programming constructs would be in programming blocks. They are designed for stored procedures, functions,

If a meta_key has a meta_value, update the meta_key name

In a table called wp_postmeta, there are ~1K meta_key’s called _wcj_custom_product_tabs_content_local_1, but only ~100 have a meta_value. What I need to do is update the meta_key name, but only for the meta_key’s that actually have a meta_value. I can select all the meta_key’s that are not empty with this: But then how do I combine the query above with the

Select Distinct Records and count other columns related to record

I am trying to create a SQL Query wherein it will pick all distinct records from the first column and do a count of all the items related to that column similar to a countifs command in Excel. I am new to SQL and I am really lost at this point. please help. Sample Table: Employee Item Weight EmpA Red

How can I make my sql trigger about inappropiate words work

I have a database with different tables in order to store photos, users, reviews, ratings… I wanna validate that no one uses “bad words” (insults) in their photos’ title or description. So I decided to create a table called ‘inappropiatewords’ where all of these bad words will be stored and then I made the following trigger: But when I try

How to prevent duplicate entry key when update

Problem explain I won’t update the last primary key of the 3 primary key concatenate. But the problem is sometimes the first and second primary key was the same for multiple records. And in this case, when I set my new value I have a duplicate entry key even I use sub-request to avoid that problem. Some Code Schemas Update

Sql join, count references including zeros

I made a simple database containing two tables, ‘country’ and ‘human’: This query shows that nobody lives in Norway, but why it says nothing about Denmark? I am using MariaDB, but prefer solutions that works on other DBs too. Answer You typically GROUP BY the same columns as you SELECT, except those who are arguments to set functions:

Advertisement