I've run into a case where a sqlite query I'm expecting to return an
error is actually succeeding and I was wondering if anyone could point
out why this query is valid.

CREATE TABLE test_table(
  k INTEGER,
  v INTEGER
);

INSERT INTO test_table( k, v ) VALUES( 4, 5 );

SELECT * FROM(
  SELECT * FROM(
    SELECT k FROM test_table
  )
  UNION ALL
  SELECT * FROM(
    SELECT k, v FROM test_table
  )
)

Here is a demo of the above: http://sqlfiddle.com/#!7/0a28f/8

I would think that unioning two selects which have a different number
of columns would return an error. If I remove the outermost SELECT *
then I receive the error I'm expecting: SELECTs to the left and right
of UNION ALL do not have the same number of result columns.

Thanks - Clay
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to