[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I am shit at SQL

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 28
Thread images: 4

File: Gordon_Gekko.jpg (37KB, 300x400px) Image search: [Google]
Gordon_Gekko.jpg
37KB, 300x400px
/g/,

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
>>
>people actually spend their lives doing this as a career
>>
>>58648667
Try subqueries.
You have a list of 150 four-letter combinations?
>>
>>58648737
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.
>>
>>58648778
Do IDs go sequentially?
>>
>>58648802
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)
>>
>>58648961
Legend - worked like a charm on a test case (Id's just numbers) - thanks!!

Will this work with wildcards? e.g. 1234*
>>
>>58648667
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 http://www.w3schools.com/sql/sql_join.asp and https://www.techonthenet.com/access/functions/string/mid.php
>>
>>58649014
Since you need to get four first characters, use ...where left(id, 4) in ( subquery)
>>
File: Regirock Computer.gif (14KB, 598x450px) Image search: [Google]
Regirock Computer.gif
14KB, 598x450px
>>58648667
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
>>
>>58649235
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.
>>
>>58649290
Yikes. I sympathize because I've actually had a client sent me DVDs of JSONs
It was a fucking surreal experience
>>
>>58649113
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!
>>
>>58649347
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?
>>
>>58648667
hire someone who knows what the fuck they are doing, or tell your boss to hire another pajeet
>>
>>58649400
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
>>
File: hammond.png (607KB, 537x633px) Image search: [Google]
hammond.png
607KB, 537x633px
>>58649235
>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.
>>
>>58649498
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
>>
>>58649530
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.
>>
>>58649581
It's not a meme if you can get a good job with it
>>
>>58649621
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.
>>
File: Technology Is Incredible.jpg (95KB, 629x497px) Image search: [Google]
Technology Is Incredible.jpg
95KB, 629x497px
>>58649663
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
>>
>>58649400
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...
>>
>>58648667
I'm MS Office access certified and I have no idea how to do that.. this certificate taught me nothing.
Thread posts: 28
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.