I am shit at SQL

Sup Forums,

I am trying to do something in MS Access using SQL which I am sure has a very easy answer - I'm a mug however so need help...

Within my database, there is a field called ID which consists of four letters followed by a random length of numbers and letters after. I have 150 IDs that I need to extract from the database.

I have tried using:
SELECT .............
FROM ........
WHERE [ID] LIKE 'XXXX*'
OR [ID] LIKE 'XXXX*'
OR [ID] LIKE 'XXXX*'
OR [ID] LIKE 'XXXX*'
OR [ID] LIKE 'XXXX*'
OR [ID] LIKE 'XXXX*'
etc
etc
etc

But realise this is fucking retarded - there must be a better way? Additionally this potato method can't do more than 100 IDs at once. How do I do 150 in one go?

I know this is probably stupidly easy but google hasn't helped so you're my only hope

Other urls found in this thread:

w3schools.com/sql/sql_join.asp
techonthenet.com/access/functions/string/mid.php
twitter.com/AnonBabble

>people actually spend their lives doing this as a career

Try subqueries.
You have a list of 150 four-letter combinations?

I literally looked at SQL for the first time ever yesterday - no idea what these are but will investigate, thanks.

I do - that bit was pretty easy as the list came from an excel.

Do IDs go sequentially?

No - pretty arbitrary, e.g. ABCD, VWXY

Don't think subqueries will help having had a quick look. How the fuck is this so difficult to achieve?

select.... from.... where ID in (select id from idtable)

Legend - worked like a charm on a test case (Id's just numbers) - thanks!!

Will this work with wildcards? e.g. 1234*

You probably want to use something like a join together with some substring matching.

SELECT -- FROM -- INNER JOIN foo WHERE foo.id == Mid(id, 0, 4)


Or something like it, where foo is your table of IDs you want to extract.

See w3schools.com/sql/sql_join.asp and techonthenet.com/access/functions/string/mid.php

Since you need to get four first characters, use ...where left(id, 4) in ( subquery)

I have never met a single person who use MS Access in my professional career.
What do you use it for OP? Not trying to be a jackass or anything, just curious

I don't use it as part of a career. I have no experience with database software and this happened to be installed on my PC.

I got given some several hundred MB file in Excel format from a retard that clearly exported it from a database. I can't access that database so I have to use access for the time being.

Yikes. I sympathize because I've actually had a client sent me DVDs of JSONs
It was a fucking surreal experience

Thanks - this worked perfectly on numbers, e.g. WHERE Left(ID,4) IN (1341,1351,1361,1371);

It doesn't seem to work IDs if I have an ID like AAA1 though? Appreciate all your help so far!

Yeah I am not best pleased but hey, I've wanted to fuck about with SQL for a while. This might be some bullshit MS version but once this is out the door I hope to pick up mySQL.

Any advice on how to go about it and what to use instead of Access from now on?

hire someone who knows what the fuck they are doing, or tell your boss to hire another pajeet

Personally I have been using Toad for all my SQL needs, but more often than not I have to do shit from the command line

It's less the client and more the language. Use codecademy or HackerRank to learn the stuff

>be me
>2006
>freshly graduated
>first job in a regional data centre for BT (UK's incumbent telephone network)
>huge company, money out the yazoo etc
>at the site I worked in, customer records, licence keys etc all run out of an MS access db that only seemed to work half the time
>everyone avoided it like the plague and it was useless

Sort of stuff happens at huge, former publicly owned companies like that. Even in the mid 2000s when I got there you could go up a floor from the data centre and walk into rooms with rack and telephone switching equipment from like the 70s that hadn't been touched in years. It was all still powered on nominally. Usually because of something dumb like "one of the lines in here runs to a desk in some government building somewhere". Never mind the government building was torn down 20 years ago...they're still paying so the company is still providing it.

I once laughed at a classmate for learning COBOL
Now he's laughing at me because he got a cushy government job maintaining old stuff while I sell my soul at a Fortune 500 on a meme agile team

Yea there's tons of old shit around.

Apparently the systems in a lot of banks are from the iron age and people who actually know how they work are literally dying off. If you can show up with a stack of memes in your resume they'll throw cash at you.

It's not a meme if you can get a good job with it

I know...but show up to any college and university and you'll have a lot of classmates and lecturers/profs laughing at you - hence the memes.

I never said the memer is at fault. He's the one actually laughing.

Awareness is more important than anything, I guess.
Some people see the eventual need of replace the old guard, so they go for those jobs
Some people predict the future correctly and get a head start on things like Python or NoSQL

Makes me wonder where do I fall on that spectrum

Navicat

google select limit statement OP

OP here. So I got it to work I think.The line in question is

WHERE Left([CAP Vehicle Code],4) IN ('AAAA','BBBB');

etc. This seems to have worked so thanks to all that helped...

I'm MS Office access certified and I have no idea how to do that.. this certificate taught me nothing.