Create a temporary table using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parallax
    New Member
    • Apr 2007
    • 10

    #1

    Create a temporary table using php

    Hi guys,

    i would like to make
    create temporary table pagamentos SELECT d.name, SUM(advanced) AS total_advance, f.salario FROM data d JOIN empregados f ON f.name = d.name where MONTH(d.date) = 04 group by name;

    and after select all

    select * from pagamentos;

    in a php script... could someone help me???

    thanks


    Danylo Iamaguchi
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Moved to MySQL forum.

    Are you trying to create a view?

    [code=sql]
    CREATE VIEW pagamentos AS SELECT d.name, SUM(advanced) AS total_advance, f.salario FROM data d JOIN empregados f ON f.name = d.name group by name;
    SELECT * FROM pagamentos where MONTH(d.date) = 04;
    [/code]

    To execute this in PHP:

    [code=php]
    // You'll probably want to execute this first line manually...
    mysql_query("CR EATE VIEW pagamentos AS SELECT d.name, SUM(advanced) AS total_advance, f.salario FROM data d JOIN empregados f ON f.name = d.name group by name");
    mysql_query("SE LECT * FROM `pagamentos` WHERE MONTH(d.date) = '04'");
    [/code]

    Check out this thread:
    Last edited by pbmods; May 15 '07, 03:53 AM. Reason: Added a link. Here's another: ?

    Comment

    • parallax
      New Member
      • Apr 2007
      • 10

      #3
      thanks... i was using create table because on the mysql's shell works ok....

      thanks a lot

      Comment

      Working...