Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If everyone could sign this (and Relsoft, take a look ;*) )
#11
Quote:
Code:
// Define sql

$sql = "SELECT foo, joe AS bar
  FROM blah
  WHERE condition
  AND other_condition
  LIMIT number, number";

// Do query
if ( !$result = @mysql_query( $sql ) )
{
  // die, with nice, formatted output. I suggest a function for this
  die('
Database Query Error!

' . mysql_error() . '
$sql
Line: ' . __LINE__ . ', File: ' . __FILE__);
}

// Get each result, and store it in $row as we go
while ( $row = mysql_fetch_array( $result ) )
{
  // Do what you will with each result
  $foo = $row['foo'];
  $joe = $row['bar'];  // Note, the AS bar clause means joe is in bar
}

[end oracle's quick db tutorial]

Wink

You may not be aware of this, but not all SQL databases use the same logical operators.

I run mySQL and it doesn't like 'AND', rather, it uses the C-Style operator 'f '&&'.

[end 1000101's quick note on oracle's quick db tutorial]
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply
#12
In standard SQL (stdSQL), which has been internationalized, it is AND, OR, and NOT Wink
Reply
#13
Be that as it may, not all people/servers may be running an SQL database which follows the standard. I was just pointing this out. Wink
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply
#14
Quote:I'm getting oodles of mysql errors, but he're a toast to rel.

*toast*

get well soon, buddy Wink
Um, um...errors? It was working fine...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#15
Get well soon, Rel.
[Image: jocke.gif]
Website: http://jocke.phatcode.net
"Some men get the world, other men get ex hookers and a trip to Arizona."
Reply
#16
Get well!
b]Hard Rock[/b]
[The Stars Dev Company] [Metal Qb flopped] [The Terror]
Stop Double Posts!
Whats better? HTML or Variables?
Reply
#17
Quote:You may not be aware of this, but not all SQL databases use the same logical operators.

I run mySQL and it doesn't like 'AND', rather, it uses the C-Style operator 'f '&&'.

[end 1000101's quick note on oracle's quick db tutorial]

I also run mysql. It handles AND fine. I think you'll find that && may have more precedence, that's all Wink

Besides, it was just an example query. There's nothing wrong with the algo which I posted.
Reply
#18
Quote:I also run mysql. It handles AND fine. I think you'll find that && may have more precedence, that's all Wink

Besides, it was just an example query. There's nothing wrong with the algo which I posted.

heh, I was just pointing out that mySQL can be quirky depending on the version you run Wink
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply
#19
Better to use Postgres then. But I can't find a free webhost that uses postgres... I have to use it through linux Sad
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)