List:General Discussion« Previous MessageNext Message »
From:jahan Date:April 26 1999 8:55pm
Subject:Re: mysql_query problem: insert .. select
View as plain text  
Thank you very much.

But you can see that I have already tried with the others in my tried list
below.

Jim Faucette wrote:

> jahan wrote:
> >
> > PostCodes
> > - ID- auto
> > - City  char 50
> > - PostCode char 20
> >
> > Addresses
> > - Name
> > - Age
> > - City char 50
> > - PostCode char 20
> >
> > This is the call I make .
> >
> > ConnectToMySQL(); // Display Error if not connected
> > UseDatabase("Statistics"); // Display Error if not used
> > if(mysql_query(&mysql,"insert into PostCodes select 0,City,PostCode
> > from Addresses where City !='CAL'")!=0)
> >    Show_error();
> >
> > And I get this error.
> > Access denied for user: 'jahan@localhost' to database 'Statistics'
> >
> > Thing that I checked.
> >
> > -> Connected to MySQL - Yes
> > -> Can insert to PostCodes , if I drop the select part
> > -> Tried the <> operator
> > -> Works very fine in command prompt ( copy /paste, exactly )
> >
> > Q. Is it built feature not to support subquery in mysql_query ?
>
> If you're running 3.22.x INSERT INTO is supported.
>
> > Q. Any expert sees any problem with the query above ?
>
> The query is ok. The problem is that jahan@localhost doesn't have
> permission to access "statistics". Check your ConnectToMYSQL routine and
> make sure it's coded correctly. Then:
>
> Either GRANT priviledges to jahan or as root add a record to mysql's
> user (and/or db) table. If the latter remember to mysqladmin reload
> after the INSERT.
>
>   jim...

Thread
mysql_query problem: insert .. selectjahan25 Apr
  • mysql_query problem: insert .. selectMichael Widenius26 Apr
  • Re: mysql_query problem: insert .. selectjahan26 Apr
  • Re: mysql_query problem: insert .. selectjahan26 Apr