Jump to content

awjudd

Staff Alumni
  • Posts

    422
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by awjudd

  1. Because that is an invalid query.  It should be IS NOT NULL.

     

    CREATE VIEW loDensity AS
    SELECT Name, SurfaceArea, Population,
    Population / SurfaceArea AS popDensity,
    LifeExpectancy
    FROM country
    WHERE LifeExpectancy IS NOT NULL
    

     

    With views, when in doubt, just try to copy and past the SQL and see the error message.

     

    ~awjudd

  2. Inserting using the set-based notation doesn't need the () around the values.

     

    The following should work:

    safe_query("INSERT INTO ".PREFIX."cup_matches ($type, $type_opp, matchno, clan1, clan2, comment, 1on1)
            SELECT a.$type, a.$type_opp, a.matchno, a.clan1, b.clan2, a.comment, a.1on1
            FROM ".PREFIX."cup_matches a, ".PREFIX."cup_matches b
            WHERE a.clan2 != b.clan2 AND a.matchno = '$ID' AND b.matchno = '$ID' AND a.$type='h' AND b.$type='h'");
    

     

    ~awjudd

  3. Unless you have a key which you can order by, there is no way of doing what you are wanting.

     

    The only way would be to add a "DisplayOrder" column and then fill that in with the corresponding order and then when selecting out of your table, you would add "ORDER BY DisplayOrder" to your query.

     

    ~awjudd

  4. As AyKay47 said, your query is doing the exact same as just a straight SELECT on that table.  However that said, to answer your question it is because you have a subquery so you need to alias that table in order for SQL to know what to refer to it as:

     

    SELECT cadetId, lastName, firstName FROM
    (
    SELECT tblcadets.pkCadetId AS cadetId, tblcadets.lastName AS lastName, tblcadets.firstName AS firstName
    FROM tblcadets AS tblcadets
    )  AS a
    

  5. SELECT DISTINCT r.id, r.title AS 'Recipe Title' , r.summary AS 'Recipe Summary', r.image , r.status AS 'Recipe Status', c.id, c.title ,c.summary, c.body, c.status,c.createdate,c.createuser,c.customerid,r.createdate, `firstname` , `lastname`
    FROM `recipies` AS r
    JOIN `customer` AS cu ON r.customerid = cu.id
    JOIN `comments`AS c ON cu.id = c.customerid
    WHERE r.status =1
    LIMIT 0 , 30
    

  6. Hi everyone,

     

    I have been coding with PHP / mySQL for 6 years now and have been freelancing on and off throughout that time.  I am now looking for a some small projects to work on.

     

    My strengths are around the back end of the application (making them work well) but I tinker with the front-end as well (however, I am not a web designer).  I also have a decent knowledge of JavaScript (I prefer to use jQuery to make my life easier).

     

    How to contact me:

    i) PM me on the PHPFreaks IRC Channel (judda)

    ii) PM me on the forums

    iii) Send me an email: http://bit.ly/rqsgxT

     

    Resume: http://bit.ly/rA0Hj9

    Development Projects: http://bit.ly/iemZYM

    Blog: http://bit.ly/uMHTRB

     

    Please feel free to contact me if you have any questions.

     

    Thanks,

    Andrew

  7. Since it returns a boolean no matter what, you don't even need the if statement.

     

    return $row->cash > $finalcash &&
                   $row->core1 > $finalcore1 &&
                   $row->core2 > $finalcore2 &&
                   $row->core3 > $finalcore3 &&
                   $row->core4 > $finalcore4;
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.