Solved

mysql php

Posted on 2015-02-01
3
21 Views
Last Modified: 2016-06-18
Hello I have a problem with mysql.

I want us values from a another table.

This is what I got:

      $q = "SELECT voorbeeld_id, voorbeelden1, voorbeelden2, voorbeelden3, voorbeelden4, voorbeelden5, voorbeeldenfile," .
                                     "             datediff(voorbeelden3, CURDATE()) AS voorbeelden4" .
                                     "  FROM voorbeelden WHERE klant_id = :klant_id" .
                                     "  ORDER BY voorbeeld_id ASC";
                              $sth = $db->prepare($q);
                              $sth->execute(array("klant_id" => $klant_id));


Now I want also from the table "klanten"  the values of "leverancier". I hope someone can help me.
0
Comment
Question by:ronbaas1
3 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 40583132
Do you want both the value from voorbeelden and from klanten in the same query?  How are the tables voorbelden and klanten related?  Do they share a field?  Perhaps klant_id?

If so ... this query should work.  Or be close enough that you can adjust it.
      $q = "SELECT voorbeeld_id, voorbeelden1, voorbeelden2, voorbeelden3, voorbeelden4, voorbeelden5, voorbeeldenfile," .
                                     "             datediff(voorbeelden3, CURDATE()) AS voorbeelden4, leverancier" .
                                     "  FROM voorbeelden inner join klanten on voorbeelden.klant_id = klanten.klant_id
                                        WHERE voorbeelden.klant_id = :klant_id" .
                                     "  ORDER BY voorbeeld_id ASC";
                              $sth = $db->prepare($q);
                              $sth->execute(array("klant_id" => $klant_id));

Open in new window

0
 

Author Comment

by:ronbaas1
ID: 40612837
thanks Daniel its working now with this code:

      $q = "SELECT voorbeeld_id, voorbeelden1, voorbeelden2, voorbeelden3, voorbeelden4, voorbeelden5, voorbeeldenfile,  leverancier," .
                                     "             datediff(voorbeelden3, CURDATE()) AS voorbeelden4" .
                                     "  FROM voorbeelden inner join klanten on voorbeelden.klant_id = klanten.klant_id
                                        WHERE voorbeelden.klant_id = :klant_id" .
                                     "  ORDER BY voorbeeld_id ASC";
                              $sth = $db->prepare($q);
                              $sth->execute(array("klant_id" => $klant_id));
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now