Skip to content
Advertisement

SQL Conditional / Case Joining / Polymorphic Associations?

I’m trying to implement something similar to Ruby on Rails’ polymorphic relationships. I have the following three tables : Events Users Organisations An event can be owner by either a user or an organisation, so my Events table includes the columns: owner_type and owner_id. I can easily list all events that belong to either users or organisations through an inner

Is there a better way to code this sqlQuery in R?

I’m writing an R script to get some database data and then do stuff with it, using the RODBC package. Currently all my sqlQuery commands are one long string; stsample<-sqlQuery(odcon, paste"…

sqlite select with condition on date

I have an sqlite table with Date of Birth. I would like to execute a query to select those records where the age is more than 30. I have tried the following but it doesn’t work: Answer Some thing like this could be used: If you are using Sqlite V3.7.12 or greater Dont use date(dateofbirth) just use dateofbirth. So your

Oracle: ‘= ANY()’ vs. ‘IN ()’

I just stumbled upon something in ORACLE SQL (not sure if it’s in others), that I am curious about. I am asking here as a wiki, since it’s hard to try to search symbols in google… I just found that when checking a value against a set of values you can do As opposed to the usual So I’m curious,

MySql conditional order by

I have this table (simplified): CREATE TABLE `my_table` ( `id` INT NOT NULL AUTO_INCREMENT , `item_name` VARCHAR(45) NULL , `price` DECIMAL(10,0) NULL , PRIMARY KEY (`id`) ) I need to select …

Similarity function in Postgres with pg_trgm

I’m trying to use the similarity function in Postgres to do some fuzzy text matching, however whenever I try to use it I get the error: If I add explicit casts to text I get the error: My query is: Do I need to do something to initalize pg_trgm? Answer You have to install pg_trgm. In debian, source this sql:

Advertisement