Skip to content

Tag: sql

PL/pgSQL SELECT into an array

Here’s my function declaration and part of the body: I want team_ids to be an array of ints that I can then use in the UPDATE statement. This function give me errors like this: Answer Faster and simpler with a FROM clause in your UPDATE statement: That aside, while operating with an array, the WHERE cla…

FULL OUTER JOIN vs. FULL JOIN

Just playing around with queries and examples to get a better understanding of joins. I’m noticing that in SQL Server 2008, the following two queries give the same results: Are these performing exactly the same action to produce the same results, or would I run into different results in a more complicat…

Java socket client/server

Hi i am trying to get some data about a socket client connecting to a mutltythreaded server process in the same machine. The server thread is triggered correctly and the client ip is retreived ok, but i cant seem to be able to send a string through the connection. THE CLIENT THE SERVER THREAD The line sent th…

rails scope and joins

I have tried everything i thought would work for this and am turning up nothing. in rails 3, I need to find all users with a cd player in their car. A car has one user and one radio, and a user belongs to a car, and a radio has many cars. I am stumbling on how I would perform

How to return default value from SQL query

Is there any easy way to return single scalar or default value if query doesn’t return any row? At this moment I have something like this code example: How to do that in better way without using IF-ELSE? Answer Assuming the name is not nullable and that Id is unique so can match at most one row.