Skip to content

Instantly share code, notes, and snippets.

@sposmen
Created May 5, 2013 15:02
Show Gist options
  • Save sposmen/5521051 to your computer and use it in GitHub Desktop.
Save sposmen/5521051 to your computer and use it in GitHub Desktop.
Table emulation in postgres and mysql
SELECT *
FROM
(
SELECT 'juan' AS data UNION
SELECT 'carlos' AS data UNION
SELECT 'pepito' AS data UNION
SELECT 'mauro' AS data
) AS tmp_names
WHERE
-- Compare data with a real table
dato NOT IN (SELECT name FROM tbl_names)
SELECT (
'{{"DG54362","13668"},
{"SCCC114952","1125137"},
{"SCCC108226","35860"},
{"SCCC48986","37257"},
{"SCCC155903","9790"}}'::varchar[][])[foo][1] AS nrofactura,
('{{"DG54362","13668"},
{"SCCC126619","37180"},
{"SCCC126622","10018"},
{"SCCC137446","169620"},
{"SCCC155903","9790"}}'::varchar[][])[foo][2] AS valorfactura
FROM
generate_series(1,5) AS foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment