?
Solved

mysql php

Posted on 2015-02-01
3
Medium Priority
?
44 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:Ron Baas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 2000 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:Ron Baas
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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 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