l33t hosting - our bandwidth pimps.  these guys r0x0rz
megatokyo - relax, we understand j00 what the hell is going on here?
who are these people?
please buy stuff or kimiko will cry...
rant and rave, tell everyone what you think.
comming soon - MT fan links and other stuff
fredart studios - the process behind the madness


    Reply to this topicStart new topic

> Limit In Access
Shish
Posted: Oct 30 2004, 09:57 AM
Quote Post


Senior l33t One
*******

Group: Active Members
Posts: 3787
Member No.: 2523
Joined: 30-June 02



I've known access to be ass for quite some time, but I got the impression that it was at least more featureful than mysql. Having had many huh.gif moments recently, I'm coming to wonder if access is actually broken at SQL support...

My current problem is this: I want to assign a (one) ticket to a pupil. currently I have
CODE
UPDATE tickets SET tickets.pupil_id = [current_pupil_id]
WHERE tickets.pupil_id = null;
, but that updates all rows. I tried adding "LIMIT 1" to the end of the query, but when I click the "switch from query builder to query results" button, it just hilights the word "LIMIT", with no message or explanation of what isn't working.

Googling round, it seems that access doesn't support LIMIT, it uses TOP instead. However when I use TOP, the same thing happens (TOP is hilighted with no explanation)


ED> Ok...
CODE
INSERT INTO letters ( pupil_id ) SELECT [current_pupil_id] AS Expr1;
seems to work for insertion, but it seems like very silly syntax :/


ED2> I want to show a form that shows the pupil's name, and how many commendations / penalties / (raffle) tickets / letters (of complaint sent to parents) there are for that pupil. Currently the following (generated by access) works, but it only shows pupils that have all four - I want it to show all pupils, and just "0" if there are none of the specified item - any ideas?

CODE
SELECT pupils.pupil_id, pupils.title, pupils.forename, pupils.surname, count_commendations.commendations, count_letters.letters, count_penalties.penalties, count_tickets.tickets
FROM (((pupils INNER JOIN count_letters ON pupils.pupil_id = count_letters.pupil_id) INNER JOIN count_penalties ON pupils.pupil_id = count_penalties.pupil_id) INNER JOIN count_tickets ON pupils.pupil_id = count_tickets.pupil_id) INNER JOIN count_commendations ON pupils.pupil_id = count_commendations.pupil_id;



<rant>
A note on the usability of open source:
MS-Access: "Reserved error(-4517); there is no message for this error"
MySQL: "ERROR 1140: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause"

People keep saying linux needs an access equivalent, but WTF? Given the choice between a real database and this, I'd vote to *avoid* an access equivalent...
</rant>

This post has been edited by Shish on Oct 30 2004, 11:08 AM
PMEmail PosterUsers WebsiteMSN
Top
Wyzard
Posted: Oct 30 2004, 11:46 AM
Quote Post


l33t One
******

Group: -Members-
Posts: 2401
Member No.: 25550
Joined: 17-March 04



QUOTE (Shish @ Oct 30 2004, 10:57 AM)
Currently the following (generated by access) works, but it only shows pupils that have all four - I want it to show all pupils, and just "0" if there are none of the specified item - any ideas?

You need to use outer joins for that, rather than the inner joins you're currently using. If you're not familiar with outer joins, I'm sure you can find some helpful articles with Google.
PMUsers Website
Top
harlock_jds
Posted: Oct 30 2004, 09:12 PM
Quote Post


may cause "certain death"
********

Group: Active Members
Posts: 13919
Member No.: 718
Joined: 18-January 02



QUOTE
I've known access to be ass for quite some time, but I got the impression that it was at least more featureful than mys


that would be wrong. i would only use access if people were shoveing glass rods up my dick and then breaking them....

as for you main problem, like Wiz says use outer joins (left outer join in your case), you would have the same issue no matter what dbs you used.

also quit depending on access to generate your sql for you, even someone like me can learn sql, so can you biggrin.gif
PMEmail PosterUsers Website
Top
Shish
Posted: Oct 31 2004, 05:45 AM
Quote Post


Senior l33t One
*******

Group: Active Members
Posts: 3787
Member No.: 2523
Joined: 30-June 02



QUOTE
also quit depending on access to generate your sql for you, even someone like me can learn sql, so can you


I've actually done lots of SQL, just not MS-SQL; and MS-SQL seems different to everyone else's, just like all their other standards >:(

There's only a week until this demo project has to be handed in, but I'm planning on making a LAMP LiveCD for my final. Writing a PHP front end from scratch and setting up the database with the sql command line is WAY easier than using access wizards...
PMEmail PosterUsers WebsiteMSN
Top
cwolves
Posted: Oct 31 2004, 09:11 AM
Quote Post


l33t One
******

Group: -Members-
Posts: 1407
Member No.: 14014
Joined: 1-May 03



Assuming you have a primary key on the table (you damn well should), you can do this:

CODE
UPDATE tickets SET tickets.pupil_id = [current_pupil_id]
WHERE tickets.primary_key=(SELECT top 1 primary_key FROM tickets WHERE pupil_id = null);
PMEmail PosterUsers WebsiteICQAOL
Top
Phredegast
Posted: Nov 2 2004, 03:14 AM
Quote Post


l33t One
******

Group: -Members-
Posts: 1955
Member No.: 554
Joined: 29-October 01



QUOTE
I've known access to be ass for quite some time, but I got the impression that it was at least more featureful than mysql.


Sorry, no. Access may be marginally more featureful than, say, Paradox, but it's not a wart on the nethermost parts of MySQL. (Yes, I know there are much more powerful databases than MySQL. I have worked with several. Access is not one of them.)

You're right about Access SQL being different from everyone else's SQL, though...
PM
Top
malcolm
Posted: Nov 2 2004, 04:08 AM
Quote Post


"万古焼"
*******

Group: Active Members
Posts: 6914
Member No.: 15283
Joined: 8-June 03



QUOTE (Shish @ Oct 31 2004, 12:57 AM)
I've known access to be ass for quite some time, but I got the impression that it was at least more featureful than mysql.

Access+JET (which is what I assume you are using) is barely one step above "Cardfile" (remember that?) - where it CAN come in use is as a front-end if you switch out the backend.

Besides, if you venture out of the most basic SQL commands you WILL find major differences between the different databases out there - it's a very non-standard standard.
PMEmail PosterUsers WebsiteMSN
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options   Reply to this topicStart new topic