Skip to content

Instantly share code, notes, and snippets.

@sufian07
Last active August 16, 2018 12:48
Show Gist options
  • Select an option

  • Save sufian07/1dca8258de8b301fef62c6809882c785 to your computer and use it in GitHub Desktop.

Select an option

Save sufian07/1dca8258de8b301fef62c6809882c785 to your computer and use it in GitHub Desktop.
<?php
sprintf(
'SELECT * FROM (%s)',
implode(
' INNER JOIN ',
array_map(
function($s,$i){
return sprintf(
"(%s) as temp%d %s",
$s,
$i,
($i > 0)?" USING (workorder_id) ":''
);
},
$subqueries,
array_keys($subqueries)
)
)
);
@sufian07
Copy link
Author

useful when you have an array of sub queries need to INNER JOIN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment