473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why is this a SQL syntax error?

select id from school_year where lower(school_year_name) = select
lower(i.enrollment_status) from interns.interns i, interns.student s
where i.unique_key = s.unique_key group by i.id;
produces

ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'select lower(i.enrollment_status) from
interns.interns i, interns.student s wher' at line 1

But if I do just this:

select lower(i.enrollment_status) from interns.interns i,
interns.student s where i.unique_key = s.unique_key group by i.id;

It works like a charm!

I just don't get it! This is why I need a DBA!

Phil

Mar 1 '06 #1
4 1236
select id from school_year where lower(school_year_name) in (select
lower(i.enrollment_status) from interns.interns i, interns.student s
where i.unique_key = s.unique_key group by i.id);

Mar 1 '06 #2

kevinjbowman wrote:
select id from school_year where lower(school_year_name) in (select
lower(i.enrollment_status) from interns.interns i, interns.student s
where i.unique_key = s.unique_key group by i.id);


Thanx but I get timeout errors now trying that query, perhaps I have
the whole thing all wrong.

Consider these tables

student

id int not null auto_increment, primary key (id),
school_year_id int not null,
unique_key varchar(16) not null
interns

id int not null auto_increment, primary key (id),
enrollment_status varchar(40) not null,
unique_key varchar(16) not null
school_year

id int not null auto_increment, primary key (id),
school_year_name varchar(40) null
OK what I want to do is extremely easy, but beyond my ability to write
this (I need a DBA!)

Foreach record in student I want to put in the field column
school_year_id the value of school_year.id where student.unique_key =
interns.unique_key **AND** upper(interns.enrollment_status) =
upper(school_year.school_year_name).

I hope that makes sense, but that's as clear as I can do it w/o a
whiteboard to show you exactly what I want.

Sorry, I simply can't do something like this, I've tried for weeks to
no avail.

Thanx
Phil

Mar 1 '06 #3
<ph**************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
OK what I want to do is extremely easy, but beyond my ability to write
this (I need a DBA!)
Philip, this is going to go on until you make this requirement clear to your
managers. If you take weeks to do things that should be done in minutes,
neither you nor the managers are getting a good deal.
Foreach record in student I want to put in the field column
school_year_id the value of school_year.id where student.unique_key =
interns.unique_key **AND** upper(interns.enrollment_status) =
upper(school_year.school_year_name).


This is the solution to what you're describing:

update students s, interns i, school_year y
set s.school_year_id = y.id
where s.unique_key = i.unique_key
and upper(i.enrollment_status) = upper(y.school_year_name)

However, this is missing something. You don't say how to relate the rows in
student to the rows in either interns or school_year. It's like there's a
join condition missing. Is there some correlation between students and
interns?

Regards,
Bill K.
Mar 1 '06 #4

Bill Karwin wrote:
<ph**************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
OK what I want to do is extremely easy, but beyond my ability to write
this (I need a DBA!)
Philip, this is going to go on until you make this requirement clear to your
managers. If you take weeks to do things that should be done in minutes,
neither you nor the managers are getting a good deal.


I made it clear, we were told it wasn't in the budget for the DBA, so
my hands were tied. I am going to make it clear that moving forward a
DBA is required, if that helps.
Foreach record in student I want to put in the field column
school_year_id the value of school_year.id where student.unique_key =
interns.unique_key **AND** upper(interns.enrollment_status) =
upper(school_year.school_year_name).


This is the solution to what you're describing:

update students s, interns i, school_year y
set s.school_year_id = y.id
where s.unique_key = i.unique_key
and upper(i.enrollment_status) = upper(y.school_year_name)

However, this is missing something. You don't say how to relate the rows in
student to the rows in either interns or school_year. It's like there's a
join condition missing. Is there some correlation between students and
interns?


There is no consistent correlation between students and interns except
the "unique_key" field, which in and of itself sometimes isn't
consistent due to bad data.

Phil
Regards,
Bill K.


Mar 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Danny Anderson | last post by:
Hola- I didn't get any responses on a previous post, so I am trying to reword my problem and post compile-able code that exhibits the behavior I am describing. On the second iteration of the...
1
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I...
6
by: Daniel Rudy | last post by:
What is wrong with this program? When I try to compile it, I get the following error. Compiler is gcc on FreeBSD. strata:/home/dcrudy/c 1055 $$$ ->cc -g -oe6-3 e6-3.c e6-3.c: In function...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
24
by: pat | last post by:
Hi everyone, I've got an exam in c++ in two days and one of the past questions is as follows. Identify 6 syntax and 2 possible runtime errors in this code: class demo {
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
37
by: miken32 | last post by:
In PHP, if a function returns an array it's fairly common to capture its return values like this: <?php list($foo, $bar, $baz) = some_function_that_return_an_array(); ?> In Javascript, would...
4
by: (2b|!2b)==? | last post by:
template <typename T1, typename T2> struct MyDbInfo { MyDbInfo():m_pEnv(0), m_tran(0), m_db(0), m_idx(0) {} MyDbInfo(CDbEnv *env, DbTxn* tran, T1* db_ptr, T2 *idx_ptr):m_pEnv(env),...
6
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.