SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    May 2013
    Posts
    199
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    whereas will be Final price, in other words calculated column per each row, how achie

    how in mysql

    when query in Rent a car Proj
    prices and cars tables - same rows
    I want json output to client script merged of the two tables (done till now) plus a column custom, whereas will be Final price, in other words calculated column per each row, how achieve the calculated column along with rest columns output all with json_encode in PHP and ajax to jQuery...?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Could you please post a data example, and the query code you've got so far?
    Your explanation isn't very clear (to me).

  3. #3
    SitePoint Zealot
    Join Date
    May 2013
    Posts
    199
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    the matter is general, how with two or three columns (in each row) calculate a new on the fly column and eject it from php/mysql to jQuery ajax... basically tell only mysql query customcolumn(to be added to result set)=col1 * col2
    well?

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Code:
    SELECT
        columnname1
      , columnname2
      , ...
      , col1 * col2 AS calculatedcolumn
    FROM ....
    WHERE ...
    Just add the calculation in your select clause, give it an alias, and it will appear in your query result set. It all depends on your PHP and JS code what else you'll have to modify.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •