I meet an error like this: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘TANAH’%’ AND a.id_bencana=b….
Recursive query in Oracle – length of chain
i’ve got table with some posts. Post have fields: post_id (key) and parent_post_id (can be null). ( If post A is replying to post B then A.parent_post_id = B.post_id). My problem is: write query to …
CTE or not for counting tree id’s referenced in secondary table
I have a simple tree table in which I reference types, sub-types (no level limit), brands and models for a simple inventory application. data structure is as shown below: (nodeIsModel is a boolean …
How to sort an EAV model that have null values?
We have an EAV (Entity-Attribute-Value) data model that can be simplified with those 3 tables: We want to sort entities on certain field: However, this will not include entities that do not have values for this field. The wanted behavior would be to have those NULL entries at the beginning of the result, likeā¦
How to write Unpivot query within Main Query?
I have a main query and in there there are columns that are bringing in data. I need to convert those columns into single column but be able to keep other elements in the query as is. Its writing …
Take % out of an SQL column
I’m trying to convert 60% -> 60 of all the columns in a table. I have tried this, but it does not work because % is an SQL operator. UPDATE host_info set host_response_rate = replace(…
Arithmetic operation on the subsets of results from a SQL groupby statement
I have a schema with sex(m/f),state_name(all states of a country), student_name,and education (phd,ms). I use following query to return total males or females in each category of education for every …
Is there a way to have a distinct clause and SUM clause at the same time?
I have this table in my database, which stores the data of requests made by a tool application. select * from details IdDetail | Folio | IdTool | Cost | 1 |53 |917 |137 | 2 |…
SQL – Ordering query by lastest date and then by ID
I have a table that looks something like this: NotificationID NotificationTypeID CreatedOn 5 2 2020-01-27 10:05:33.147 4 13 2020-01-24 15:…
Concat 2 column in one using codeigniter
I want to concatenate the first and the last name as full name in my query. $query = $this->db->select(‘CONCAT(w.firstName,” “,w.lastName) as fullName,w.ID,w.firstName,w.lastName, w….