SQL: Combining two select queries, using results from the first I know this will either use a left join or left outer join or something like that, but these types of queries always throw me off.  I have two tables:  categories  ID    CatName          CatSlug 1     Big Shirts       big-shirts   items  ID    ItemName         Category    Price    ... 1     Big Red Shirt    1           20.00   So I am trying to return all items in a given category, queried by the category slug. I also need to return the category name. So now, my two queries are like:  $return = array();  $query = "SELECT * FROM categories WHERE CatSlug = :CatSlug LIMIT 1";   $param = array(     'CatSlug' =&gt; $slug );  $result = $this-&gt;Db-&gt;selectOne($query, $param);  if ($result) { // If result exists      $return['Category'] = $result['CatName']; // Need to return cat name      $query = "SELECT * FROM items WHERE Category = :Category";       $param = array(         'Category' =&gt; $result['ID']     );      $result = $this-&gt;Db-&gt;selectAll($query, $param);      if ($result) { // If result exists          $return['Items'] = $result;      } else { // If result does not exist          $return['Items'] = array();      } // End if result does not exist  }  return $return;   So, I am returning an array with two keys: Category contains the CatName value in the categories table, and Items contains an array of all items inside that category, or a blank array if there are none.  How can I combine these two queries?
What is the difference between "INNER JOIN" and "OUTER JOIN"? Also how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in?
Why did my windshield freeze instantaneously? Keyboard backlight not working on an Asus N56V See .  The FN keys are not working  Using answer in  I installed the asus-wmi-dkms_0.2_all.deb.gz package  Now, using xev I see that the keys emit keycodes (for backlight keys xev says for fn-f3 and fn-f4 keycode 237)  But no keyboard backlight, also volume keys have no effect  ================ original question ========================================  I cannot enable the keyboard backlight Seems that the leds class is missing I've not found the classes used in   Description of my framework:  ===========================================================  Machine: Asus N56V laptop  ===========================================================  Software   Kubuntu 12.04 amd64  kernel (3.5.0.5-generic) and drivers from xorg-edgers fresh X crack ppa   ===========================================================  Hardware and problems   after installation do not boot - SOLVED using boot-repair every couple of hours the system freezes - SOLVED using 3.5 kernel keybord FN keys - NOT WORKING Keyboard backlight - NOT WORKING Nvidia GEFORCE GT - NOT USED glxgears says 60 fps Ethernet Atheros card - SOLVED install alx driver external subwoofer - SOLVED adding options snd-hda-intel model=asus-mode4   ==========================================================  Solutions  see the answers to the  and  question.  ========================================================== Get path to application? How can a user determine the path to an application being showed in launcher?  This is meant for non-programmers or experts, so terminal commands are not really suited for them. Why: we need to make our users able to drag files/folders on our applications, a standard OS feature entirely missing in Ubuntu. What is the difference between Halt and Shutdown commands? What is the difference between the halt and shutdown commands? What is the usage of Zero Ohm & MiliOhm Resistor? I am new to PCB design and I noticed that some schematics use 0Ω or 100mΩ resistors. What is their purpose and why do we need to use them in our PCB design?  Normally if we wish to probe how much current the load is taking, we put a jumper pin across the PCB trace (then measure current across the pin using a multimeter). Adding resistors for this purpose seems like it would waste a lot of PCB real-estate. Is this the sole reason why 100mΩ resistors are being placed (since I = V/0.1Ω) instead of a jumper pin?   If so, is there any consideration we should take when placing such a mΩ resistor on board so it doesn't affect the signal or behaviour of the circuit? How to prove Vandermonde's Identity: $\sum_{k=0}^{n}\binom{R}{k}\binom{M}{n-k}=\binom{R+M}{n}$? How can we prove that     $$\sum_{k=0}^{n}\binom{R}{k}\binom{M}{n-k}=\binom{R+M}{n}?$$   (Presumptive) Source: Theoretical Exercise 8, Ch 1, A First Course in Probability, 8th ed by Sheldon Ross. Set of discontinuity of monotone function is countable The result I am trying to prove is the following:     Let $F:\Bbb R\to\Bbb R$ be increasing. Then the set of points, at which it is discontinuous, is countable.   I have been reading this form Folland's Real Analysis and he proves this by considering the sum $\sum_{|x|&lt;N}[F(x^+)-F(x^-)]$ which has to be finite by some sort of telescoping sum. Now, I am not sure how he defines this sum. I am assuming he does this by using nets (let me know if there is another way to look at this), but he doesn't introduce the concept of nets until the next chapter. So I was looking for some other ways to prove this result and I found the following result (from Stein-Shakarchi) which is quite similar but assumes $F$ to be bounded.      A bounded increasing function $F$ on $[a,b]$ has at most countably many discontinuities.   This is shown by using the density of rationals in $\Bbb R$, i.e. $\exists r_x\in\Bbb Q$ s. t. $F(x^-)&lt;r_x&lt;F(x^+)$ corresponding to each point of discontinuity $x$.   Now I feel like there shouldn't be a problem in doing the exact same thing for unbounded increasing function. Is this right? Secondly how does this proof relate to the first one? I feel like there isn't much of a difference between the two proofs. To be precise I think that the previous sum is well defined/finite because of this countability of discontinuous points. What do you think about this way of thinking?  Edit. Here is the Folland's proof in more detail:  Since $F$ is increasing, the intervals $(F(x^-),F(x^+))$ are disjoint for all $\forall x\in\Bbb R$. Moreover,  $\forall|x| &lt; N$ such intervals are contained in $(F(-N),F(N^+))$ and so  $$\sum_{|x|&lt;N}[F(x^+)-F(x^-)] \leqslant F(N) - F(-N) &lt; \infty. $$ Hence the set $\{ x \in (-N,N) : F(x^+) \neq F(x^-)\}$ is countable. How to edit `postgresql.conf` with pgAdmin 3? Volume of $T_n=\{x_i\ge0:x_1+\cdots+x_n\le1\}$ Let $T_n=\{x_i\ge0:x_1+\cdots+x_n\le1\}$. I know $T_n$ is tetrahedron.  My question: How can I compute the volume of $T_n$ for every $n$? Showing $\sum\limits_{p \in P} \frac{1}{p}$ where $P$ is the set of all primes is divergent Phase shift of 180 degrees of transversal wave on reflection from denser medium Can anyone please provide an intuitive explanation of why phase shift of 180 degrees occurs in the Electric Field of a EM wave, when reflected from an optically denser medium?  I tried searching for it but everywhere the result is just used.The reason behind it is never specified. Unicode input retrieved via PrimeFaces input components become corrupted Prove or show a counter example for: $\forall a, b, c \in \mathbb Z$, if $ab\mid c$ then $a\mid c$ and $b\mid c$ I'm working on my Discrete Mathematics homework and they are asking me this:  Prove or show a counterexample for: $\forall a, b, c \in \mathbb Z$, if $ab\mid c$ then $a\mid c$ and $b\mid c$  I'm not completely sure how to prove it. I was thinking to find a counterexample like zero but I'm not sure if that it's going to work. Or maybe try to approach it backwards?   I'm a little bit lost What techniques are available for collapsing (or pooling) many categories to a few, for the purpose of using them as an input (predictor) in a statistical model?    Consider a variable like  (discipline chosen by an undergraduate student). It is unordered and categorical, but it can potentially have dozens of distinct levels. Let's say I want to use major as a predictor in a regression model.  Using these levels as-is for modeling leads to all sorts of issues because there are just so many. A lot of statistical precision would be thrown away to use them, and the results are hard to interpret. We're rarely interested in specific majors -- we're much more likely to be interested in broad categories (subgroups) of majors. But it isn't always clear how to divide up the levels into such higher-level categories, or even how many higher-level categories to use.  For typical data I would be happy to use factor analysis, matrix factorization, or a discrete latent modeling technique. But majors are mutually exclusive categories, so I'm hesitant to exploit their covariance for anything.  Furthermore I don't care about the major categories on their own. I care about producing higher-level categories that are coherent with respect to my regression outcome. In the binary outcome case, that suggests to me something like linear discriminant analysis (LDA) to generate higher-level categories that maximize discriminative performance. But LDA is a limited technique and that feels like dirty data dredging to me. Moreover any continuous solution will be hard to interpret.  Meanwhile something based on covariances, like multiple correspondence analysis (MCA), seems suspect to me in this case because of the inherent dependence among mutually exclusive dummy variables -- they're better suited for studying multiple categorical variables, rather than multiple categories of the same variable.  edit: to be clear, this is about collapsing categories (not selecting them), and the categories are predictors or independent variables. In hindsight, this problem seems like an appropriate time to "regularize 'em all and let God sort 'em out". Glad to see this question is interesting to so many people! Motley fool says you can make $15,978 more per year with Social Security. Is this for real? The Motley fool has an ad campaign that says you can make $15,978 more per year on Social Security by doing 17 minutes of work using a legal loophole.  I don't want to link to their ad (although, you can find it by searching ).  What are they talking about here?  Is there any truth to this?  If someone could explain it to me without me having to watch the entire ad video or subscribe to their newsletter, I'd appreciate it. In classical logic, why is $(p\Rightarrow q)$ True if both $p$ and $q$ are False? I have a third-party library which consists mainly of a large number of static (.a) library files.  I can compile this into a single .a library file, but I really need it to be a single .so shared library file.  Is there any way to convert a static .a file into a shared .so file?  Or more generally is there a good way to combine a huge number of static .a files with a few .o object files into a single .so file? Why can't Transporter technology be used as a weapon? Seems like this is the most powerful weapon of all: transport your enemy into a bulkhead, planet, etc. Transport your enemy's ship inside a planet, etc.  Is there some technical reason that it can not be used this way? Why is it "come" rather than "go" ? Dimensioning of a technical drawing in TikZ