RE: SQL question

2002-09-27 Thread Derek Scruggs

I just tried it and it works fine. It doesn't solve my similar problem,
which is related to letters coming *before* numbers, but the parser doesn't
reject it.

Wish I could offer a solution, but I'm not very knowledgable about MySQL
internals  config.

-Derek

 -Original Message-
 From: John Almberg [mailto:[EMAIL PROTECTED]]
 Sent: Friday, September 27, 2002 9:30 AM
 To: Mysql
 Subject: FW: SQL question



 Nope. I've tried every combination I can think of of these ideas. They all
 give syntax errors. I don't think arithmatic is allowed in an ORDER BY
 clause. Doesn't even work on an INT field.

 -- John



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Meidumtext vs. varchar

2002-09-25 Thread Derek Scruggs

Hi All,

I've built a survey application in MySQL that allows people to enter
free-form comments. In processing the input, if the comments string is less
than 256 characters long, I save it to a varchar column; if longer, I use a
mediumtext.

This works fine, but I'm wondering if I'm getting any real value from it. Is
it inherently faster to retrieve varchars than mediumtext, even if the
mediumtext is holding small (256 characters) values? What about for
searching on these field types?

-Derek


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: optimizing inserts

2002-09-23 Thread Derek Scruggs

 Where might I find information about optimizing inserts to MySQL tables.

In Paul DuBois's excellent MySQL from New Riders, there is a section about
loading data efficiently in which he talks a little about inserts. In a
nutshell, LOAD DATA is faster than INSERT, the fewer the indexes the faster,
the shorter the statements the faster, let MySQL handle default values...
and a few other things.

If you're using INSERT, the syntax INSERT INTO table VALUES(...),(...),...
is preferred because it allows you to batch multiple inserts.

Which leads me to a follow-on question for Paul if he's reading. If batching
is not an option, is this syntax still faster than INSERT INTO table SET
col=value,... ?

I'm working on an OO app and would like to use the objects for batch imports
 exports. I know this will be slower, of course, but the table
relationships are rather complex, the objects are stable and debugged and
I'd rather not introduce a new uncertainty, especially since import/export
will be used rarely. That said, the objects' insert methods use the SET
col=value syntax and I'm wondering if I should re-write them to use the
VALUES(...) syntax. I'd rather not do that if there's no performance
benefit.

-Derek

PS This book is my bible for MySQL and I highly recommend it.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Inserting into two tables...

2002-09-23 Thread Derek Scruggs

 I have db that has two tables that I am needing to post the same
 information
 into both tables, I can't use ID. So I am want to see if there is a sql
 statement that will let me or how I can do with a php page.

I'm not a SQL guru, but I'm pretty sure SQL doesn't allow this. (Objects in
PostgreSQL and other object databases essentially allow this, but I suspect
the underlying SQL is iterative.)

But it's pretty simple to do. Just create your insert statement inside a
function with a variable for the table name, then call the function with the
table names.

?
function foo($table) {
   $sql=INSERT INTO $table VALUES(...);
   //connect to db
   $result=mysql_query($sql);
   //error handling here
}

foo(table1);
foo(table2);
?

If you need them to have the same ID and you're using autoincrement, you can
add an optional parameter $ID and have the function return last_insert_id if
$ID is not set. Capture the ID the first time you call the function, then
pass that ID as a parameter the second time.

$ID=foo(table1);
foo(table2,$ID);

See http://www.php.net/manual/en/functions.arguments.php for more info on
function arguments in PHP.

-Derek


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




OT: Report writer

2002-09-23 Thread Derek Scruggs

Hi All,

This is a little OT, but I'm looking for a report writer/server for
Apache/MySQL. There are lots  of report writer/servers out there, but the
ones I've found so far either 1) work only on Windoze or 2) cost a lot of
money. I'm just looking for a basic tool that allows me to design relatively
simple reports on a Windoze desktop and upload the report schema to a
Linux/Apache web server, which generates the reports on the fly. It would be
great if it used PHP so I could tweak the internals, but I'm not holding my
breath on that.

I'll probably end up writing my own module, but it would be nice if there
were something available that automated some of the more mundane stuff such
as pagination, parameters etc.

TIA,
Derek


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php