Solved

mysql php

Posted on 2015-02-01
3
25 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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 …

778 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