sql-server-2008,tsql,join,cardinality,scalar-subquery

In MSSQL it appears that isnull only evaluates its second argument if the first is null. So in general you can say select isnull(x, 0/0) to give a query which returns x if non-null and dies if that would give null. Applying this to a scalar subquery, select 42, isnull((select...

mysql,join,subquery,scalar-subquery

It appears you want something like this: select radicados.* from radicados join estudiantes on radicados.asignado = estudiantes.estudianteid join usarios on estudiantes.usario = usarios.usarioid where usarios.nombre = $nombre_usuario In constructing such a query, start with the FROM clause. Join together the various tables containing the needed data, based on the relationships...

mysql,sql,sql-update,correlated-subquery,scalar-subquery

Using the structure you have, you need to move the distance calculation into the WHERE and ORDER BY clauses: SET c.location_id = ( SELECT l.id FROM Location AS l WHERE l.latitude BETWEEN p.latitude - (a.radius / a.distance_unit) AND p.latitude + (a.radius / a.distance_unit) AND l.longitude BETWEEN p.longitude - (a.radius /...

sql,sql-server,sql-server-2008,tsql,scalar-subquery

This statement is causing the problem: SET @ItemId = (select itemid from janel.dbo.item WHERE janel.dbo.item.itemnumber like 'c-%' and listprice > 0 ); If there is more than one row which satifies the condition then the error will occur because the SET statement expects there to be a scalar value returned...