Skip to content

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 …

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(…

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….