CodeIgniter Forums
Simple query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Simple query (/showthread.php?tid=27392)



Simple query - El Forum - 02-09-2010

[eluser]Anonymous[/eluser]
Something tells me this is a stupid question, but i'll ask it anyway

I have a simple table in my db:

Code:
[pages]
  -page_id
  -page_name
  -page_content
  -page_parent_id

Code:
SELECT *
FROM pages
WHERE page_parent_id = $page_name

I want to select all pages where page_parent_id = $page_slug.
Do i have to run 2 querys to get the page_id of the $page_slug given ? Or is this possible in 1 query?


Simple query - El Forum - 02-09-2010

[eluser]Sbioko[/eluser]
Use UNION(as I remember). With Codeigniter's ActiveRecord I slowly started to forget MySQL :-)