Re: multiple mysql statements in single php request

2003-07-09 Thread Rick Pasotto
Never mind. I've solved my problem. My create statement had an unquoted
date in the select part. It works correctly now.

On Wed, Jul 09, 2003 at 03:29:11PM -0400, Rick Pasotto wrote:
> Is it possible to issue multiple sql statements in a single php request?
> (Probably not since I get a syntax error. mysql 4.0.13).
> 
> For example:
> 
> $result = mysql_query("drop table if exists tmptab;
>   create temporary table tmptab select * from othertab;
>   select * from tmptab where ");
> 
> Or do I need to do 'mysql_query' three times?
> 
> (I know the temp table is not necessary for the example but the real
> query is more complex and does need it.)
> 
> My problem is that I've got a query similar to the above that works
> correctly when I call it from the command line as
> 
> 'mysql database < query.sql'
> 
> but gives a wrong answer when I issue it from php. I've triple and
> quadruple checked that the queries are the same. The only difference
> I've been able to see is the single versus multiple calls.
> 
> Any other ideas?
> 
> BTW, it's only one row of the result set that's wrong.
> 
> -- 
> "A little inaccuracy sometimes saves tons of explanation."
>   -- H. H. Munro (Saki)
> Rick Pasotto[EMAIL PROTECTED]http://www.niof.net
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
> 

-- 
"Any fool can criticize, condemn, and complain -- and most fools do."
-- Dale Carnegie
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



multiple mysql statements in single php request

2003-07-09 Thread Rick Pasotto
Is it possible to issue multiple sql statements in a single php request?
(Probably not since I get a syntax error. mysql 4.0.13).

For example:

$result = mysql_query("drop table if exists tmptab;
create temporary table tmptab select * from othertab;
select * from tmptab where ");

Or do I need to do 'mysql_query' three times?

(I know the temp table is not necessary for the example but the real
query is more complex and does need it.)

My problem is that I've got a query similar to the above that works
correctly when I call it from the command line as

'mysql database < query.sql'

but gives a wrong answer when I issue it from php. I've triple and
quadruple checked that the queries are the same. The only difference
I've been able to see is the single versus multiple calls.

Any other ideas?

BTW, it's only one row of the result set that's wrong.

-- 
"A little inaccuracy sometimes saves tons of explanation."
-- H. H. Munro (Saki)
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



left join help

2003-07-09 Thread Rick Pasotto
One of these days I will maybe understand...

Using MYSQL 4.0.13, debian linux

create table members (
id unsigned int autoincrement,
name
)

create table activity (
id unsigned int autoincrement,
description
)

create table history (
id unsigned in autoincrement,
date date,
member_id unsigned int,
activity unsigned int
)

What I need:
1) only records for a particular date
2) there should be at least one record for each activity
3) there may be multiples of the same activity on a given date
4) there may be multiples of the same member on a given date
5) not all members will be listed
6) the members.name result field may be NULL

SELECT history.date, activity.description, members.name
???
WHERE history.date = '-MM-DD'

-- 
"A little inaccuracy sometimes saves tons of explanation."
-- H. H. Munro (Saki)
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Why "unsigned" doesn't work?

2002-12-29 Thread Rick Pasotto
On Sun, Dec 29, 2002 at 04:06:39PM +0200, Octavian Rasnita wrote:
> Hi all,
> 
> I've tried the following SQL line in MySQL 4.05 for Windows and it told me
> that there is an error starting from "unsigned...".
> 
> mysql> create table aaa(id int not null unsigned, name text);
> 
> Can you tell me why doesn't it work?

What is an 'unsigned not null'?

The syntax calls for (col_name type [NOT NULL] ...).

Two of the valid types are 'int' and 'int unsigned'.

Try 'create table aaa(id int unsigned not null, name text);'

-- 
"All government is, in its essence, organized exploitation, and
in virtually all of its existing forms it is the implacable enemy
of every industrious and well-disposed man." --- H. L. Mencken
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

-
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




python classes and mysql

2002-08-13 Thread Rick Pasotto

If I create multiple classes in python to deal with different aspects of
a program and each of those classes needs to access mysql what is the
best way of handling connections/cursors?

1) Each class opens a connection and creates a cursor.
2) The toplevel opens a connection which is passed to the class which
   then creates a cursor.
3) The toplevel opens a connection and creates a cursor which is passed
   to the class.

-- 
"No one can make you feel inferior without your consent."
-- Eleanor Roosevelt
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

-
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




changing column to auto-increment

2002-06-14 Thread Rick Pasotto

I have a table whose key is currently a regular int. I am manually
incrementing it using a second table. If I alter the column type to
auto-increment will the next insert find the current highest number and
increment that or do I need to do something more?

[mysql - sql]

-- 
"Pollution is a result of immature technology.  Pollution is waste and
ignorance."
"The faster the economic growth rate, the faster pollution levels decline."
--- Greg Rehmke
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

-
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: Date comparisions...

2001-05-02 Thread Rick Pasotto

On Wed, May 02, 2001 at 04:00:17PM +0100, Roo wrote:
> Hi all,
> 
> I was recently attempting what I thought would be an easy search. I
> wanted to return all records with a birthdate (a DATE column) 'within'
> 30 days of the current date.
> 
> The birthdate is stored as a -MM-DD, I have been having lots of
> trouble getting MySQL to return the correct records, my problems are..
> 
> 1.I need to ignore the year value as all birthdates will be previous
> to the current if the year is included.  2.I need to check if a
> birthdate is in the same month as the current month and that its day
> is not less than the current day.  3.Then I need to check how many
> days there are left in the current month, take it away from 30 and
> then check for birthdates in the following month within that many
> days.
> 
> So much for being a simple problem!
> 
> Anyone have any experience of doing this..?
> 
> LINUX..MySQL 3.22.32 on apache
> 
> thanks a bunch for any info

You're making it much too complicated. Try:

select birthdate from table
where concat(substring(now(),1,4),substring(birthdate,5,6))
between date_sub(now(), interval 30 day)
and date_add(now(), interval 30 day)

Much to my surprise this did not fail when there were birthdays
on Feb. 29.

-- 
"The action required to sustain human life is primarily intellectual:
everything man needs has to be discovered by his mind & produced by
his effort...  Since knowledge, thinking, & rational action are
properties of the individual, since the choice to exercise his
rational faculty or not depends on the individual, man's survival
requires that those who think be free of the interference of those who
don't.  Since men are neither omniscient nor infallible, they must be
free to agree or disagree, to cooperate or to pursue their own
independent course, each according to his own rational judgment.
Freedom is the fundamental requirement of man's mind."
-- Ayn Rand
   Rick Pasotto email: [EMAIL PROTECTED]

-
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: newbie question on variable length records.

2001-05-01 Thread Rick Pasotto

I think he may be trying to put a variable number of *fields* in each
record. This of course cannot be done directly. If that is what he wants
he will need to have his own program merge/parse the data into a fixed
number of MySQL fields (columns).

On Tue, May 01, 2001 at 09:53:21AM -0400, Tim wrote:
> 
> This is straight from 7.7.1 of the MySQL manual:
> 
> *
> If any column in a table has a variable length, the entire row is
> variable-length as a result. Therefore, if a table contains any
> variable-length columns (VARCHAR, TEXT, or BLOB), all CHAR columns longer
> than three characters are changed to VARCHAR columns. This doesn't affect
> how you use the columns in any way; in MySQL, VARCHAR is just a different
> way to store characters. MySQL performs this conversion because it saves
> space and makes table operations faster. See section 8 MySQL Table Types.
> *
> 
> http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
> 
> - TIM FRASER
> 
> > Hi,
> >
> > I am a newbie to Mysql.
> >
> > I would like to know how to create a table with
> > variable length records?
> >
> > i have an object with following variables:
> > varchar v, int a, int b, int c.
> >
> > and i want to store variable number of such objects
> > into the rows.
> > varchar v is the primary key.
> >
> > the entries in the table would look like:
> > v11,a11,b11,c11,a12,b12,c12,a1,b13,c13
> > v21,a21,b21,c21,a22,b22,c22
> >
> > Can you please help me with my problem?
> >
> > Thanx in advance.
> >
> > -Sagar
> >
> >
> >
> >
> > __
> > Do You Yahoo!?
> > Yahoo! Auctions - buy the things you want at great prices
> > http://auctions.yahoo.com/
> >
> > -
> > 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
> >
> 
> 
> 
> -
> 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
> 

-- 
"Tyranny is any political system (whether absolute monarchy or fascism
or communism) that does not recognize individual rights (which
necessarily include property rights).  The over-throw of a political
system by force is justified only when it is directed against tyranny;
it is an act of self-defense against those who rule by force.  For
example, the American Revolution."
-- Ayn Rand
   Rick Pasotto email: [EMAIL PROTECTED]

-
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: complicated query

2001-04-20 Thread Rick Pasotto

On Fri, Apr 20, 2001 at 03:09:32PM -0600, Jeff Shipman - SysProg wrote:
> }
> } You don't need to create another column, just use:
> }
> } ORDER BY category = 'other', category
> }
> 
> Are you sure this works? My query is:
> 
> select category,subcategory from categories ORDER BY
> category = 'other', category;
> 
> And I get:
> 
> ERROR 1064: You have an error in your SQL syntax
> near '= 'other', category' at line 1

Yes. And I of course tested before I posted. I also tried 

ORDER BY category in ('cat1','cat2'), category

which worked.

I'm running 3.23.36 on debian linux.

Well, actually, rather than create a new table, I used an existing one.
The actual statement was

select last_name from mizpah where first_name like 'fr%' order by
last_name = 'crosby', last_name;

-- 
"Moderation in temper is always a virtue; but moderation in
 principle is always a vice."
-- Thomas Paine, _The Rights of Man_ (1791)
   Rick Pasotto email: [EMAIL PROTECTED]

-
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: complicated query

2001-04-20 Thread Rick Pasotto

On Fri, Apr 20, 2001 at 03:39:59PM -0400, Steve Werby wrote:
> "Jeff Shipman - SysProg" <[EMAIL PROTECTED]> wrote:
> > I would like to do something similar to an ORDER BY
> > in one of my select statements, but I'mt not sure
> > how to do something as complicated as this:
> >
> > I have two columns, category and subcategory, that
> > I am retrieving. I would like category and subcategory
> > to be sorted alphabetically. This is easy with an
> > 'ORDER BY 1 2', but I would like categories that
> > are named 'other' to be put off until the end. So,
> > I'd get something like this:
> >
> > abcd
> > ghikj
> > z
> > other
> >
> > Is there a way to do this type of query? Thanks in
> > advance.
> 
> If you make the category field an ENUM type then it will automatically be
> sorted in the same order as the order of the ENUM values.  Another option
> would be to create an additional column (or 2 columns if the same problem
> occurs in "subcategory") and assign records with a category of "other" a
> value of 1 and assign all other records a default value of 0.  Let's call
> the new field "order_1" Then you could construct an ORDER BY clause like:
> 
> ORDER BY order_1, category...

You don't need to create another column, just use:

ORDER BY category = 'other', category

-- 
"Freedom is just chaos with better lighting."
-- Alan Dean Foster
   Rick Pasotto email: [EMAIL PROTECTED]

-
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




python on windows / mysql on linux

2001-04-05 Thread Rick Pasotto

Could someone explain to me *exactly* what I need to do to access a
mysql server on my linux box from a python program on my windoz box?

The python program works fine on the linux box and I think I should
be able to run it on the windoz box simply by changing the connection
parameters but I can't figure out how to install MySQLdb.

I have the MySQL-python-0.3.5-win32-1.zip file but there are no
instructions that explain what needs to go where. I've run the 
'setup.py build' and 'setup.py install' but still get 'module not found'
when I try to import MySQLdb.

The python on the windoz box is a vanilla BeOpen 2.0.

-- 
"Good intentions will always be pleaded for every assumption of
authority.  It is hardly too strong to say that the constitution was
made to guard the people against the dangers of good intentions. There
are men in all ages who mean to govern well, but they mean to govern.
They promise to be good masters, but they mean to be masters."
        -- Noah Webster
   Rick Pasotto email: [EMAIL PROTECTED]

-
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: About reserved words: mySQL's dirty little secret

2001-02-04 Thread Rick Pasotto

If reserved words are such a big deal why are they not even mentioned
in the DuBois book? Or if they are I haven't come across it. Certainly
'reserved' does not appear in the index.

-- 
"Democracy extends the sphere of individual freedom; socialism
restricts it.  Democracy attaches all possible value to each man;
socialism makes each man a mere number.  Democracy and socialism have
nothing in common but one word: equality.  But notice the difference:
while democracy seeks equality in liberty, socialism seeks equality in
restraint and servitude."
-- Alexis de Tocqueville
   Rick Pasotto email: [EMAIL PROTECTED]

-
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: display width in mysqlgui

2001-01-16 Thread Rick Pasotto

On Tue, Jan 16, 2001 at 03:04:23PM +0200, Sinisa Milivojevic wrote:
> Gerald L. Clark writes:
>  > Rick Pasotto wrote:
>  > > 
>  > > SELECT concat(last_name,", ",first_name) as name from members
>  > > 
>  > > results in a column that is much wider than necessary. Adding trim() to
>  > > the concat() nor to the components makes any difference.
>  > > 
>  > > Can the column width be specified?
>  > > 
>  > > --
>  > It doesn't for me.
>  > What table type, and field types are you using?
> 
> Hi!
> 
> One of the options in options dialogue is a default maximum  column
> width. 

Which applies to *all* columns, not individual ones.

> But all column widths  are resizeable, of course.

What is this "of course" bit? There is no "of course."

If you mean resizing with the mouse - of course I tried that.

It didn't work.

The little double-headed arrow displayed but the column wouldn't resize.

I wouldn't have asked the question if the answer were so obvious.

After reading your response I thought I would, just for kicks, try
again with the mouse. This time it worked - a couple of times. Then
it stopped. Why? I have no clue. I'm doing exactly the same thing.
Does your left toe have to be pointing a certain direction?

And I never got the extreme right hand column to resize.

-- 
"The state is that great fiction by which everyone tries to live at the
expense of everyone else."
--Frederic Bastiat
   Rick Pasotto email: [EMAIL PROTECTED]

-
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: display width in mysqlgui

2001-01-15 Thread Rick Pasotto

On Mon, Jan 15, 2001 at 10:39:15AM -0600, Gerald L. Clark wrote:
> Rick Pasotto wrote:
> > 
> > SELECT concat(last_name,", ",first_name) as name from members
> > 
> > results in a column that is much wider than necessary. Adding trim() to
> > the concat() nor to the components makes any difference.
> > 
> > Can the column width be specified?
> > 
> > --
> It doesn't for me.
> What table type, and field types are you using?

varchar(30)

Did you notice that I said 'mysqlgui' and not 'mysql'?

-- 
"Moderation in temper is always a virtue; but moderation in
 principle is always a vice."
-- Thomas Paine, _The Rights of Man_ (1791)
   Rick Pasotto email: [EMAIL PROTECTED]

-
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




display width in mysqlgui

2001-01-15 Thread Rick Pasotto

SELECT concat(last_name,", ",first_name) as name from members

results in a column that is much wider than necessary. Adding trim() to
the concat() nor to the components makes any difference.

Can the column width be specified?

-- 
"Money is the material shape of the principle that men who wish to
deal with one another must deal by trade & give value for value."
-- Ayn Rand
   Rick Pasotto email: [EMAIL PROTECTED]


-
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