We help IT Professionals succeed at work.

New podcast episode! Our very own Community Manager, Rob Jurd, gives his insight on the value of an online community. Listen Now!


SQL querys that gives me from one table into another.

Jazzy 1012
Jazzy 1012 asked
Last Modified: 2017-03-13
I have this basic query:

select * from sites where user_id = '1'

Open in new window

I get this output:
id      name         url                                    user_id
2	My blog	demc.com			         1
7	demo.e	http://demo.com/		1	

Open in new window

I want it to search for these urls inside another table called "URLS"
Something like where url LIKE "demo.com%" where date LIKE "Y-m-d%" (since there is also minutes and seconds)
and then give me the number of rows from the URL table
Watch Question


function getComments($object){
      $sites_comment = DB::select('url')->from('sites')
      ->where('user_id', $object->current_user->id)
      if ($sites_comment == false) return 0;
      //var_dump($sites_comment);die; I get the URL SO I WANT THE BOTTOM QUERY TO GET ME THE COUNT FOR THE SAME URL AND TODAYS DATE, but now they are acting like 2 separate queries.
      $script = "select count(*) as count from an_a";
      $data = DB::query($script)->execute();

      if($data == false) return 0;

      $count = $data[0]['count'];

      return $count;
Most Valuable Expert 2015
Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.