Jump to content

BigP

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://newsphp.sourceforge.net/

Profile Information

  • Gender
    Not Telling
  • Location
    Ireland

BigP's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. BigP

    SQL query help

    Hello! I\'ve been trying to optimize a few of my queries in a program I wrote but I\'m getting a little lost. Here is a half written SQL query: $sql = \'SELECT e.id, e.posterid, e.titletext, m.username\' . \' FROM phpnews_news e, phpnews_posters m\' . \' WHERE e.posterid = m.id\' . \' ORDER BY e.id DESC\'; $SQL_query = mysql_query($sql); while ($posts = mysql_fetch_array($SQL_query)) { // Do stuff } My tables are like so: phpnews_news table holds all the news. phpnews_posters table holds people allowed post news. The name of the person who posts the news is in the phpnews_posters table. A foreign key, \"posterid\" is used to link them to an article. There\'s also a field called \"postername\" that stores the postersname in the phpnews_news table in case that particular news poster is deleted. So, as you can see I am able to get the posters name from the phpnews_posters table, but I don\'t know how to use the \"postername\" field from phpnews_news if there is no matching ID in the posters table. So basically if this isn\'t true: . \' WHERE e.posterid = m.id\' Any help is greatly appreciated! You\'d be helping me make an Open Sorce project better by helping me here! Thanks!
×
×
  • 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.