PDA

View Full Version : SQL query question


shwaip
5 Oct 2003, 10:10 PM
My CS220 project is to build a java program that interacts with a database somehow. Our project basically queries a pre-built database. I got stuck with the code-bitch role (the rest of my group aren't too good at it).

I've gotten most of the queries that I want to work, but I cannot make a filename search that does not match exactly. It takes a string from the user, and creates a query using that. I've tried the using the asterisk as a wildcard, but it does not seem to work. The book that was reccomended for the class did not address this topic, or I just cannot find it. Help meh pls!

a2jfreak
5 Oct 2003, 10:41 PM
You are using LIKE, right?

SELECT * WHERE field LIKE "%blah"
Or whatever suits your needs.

shwaip
5 Oct 2003, 10:43 PM
Like (heh) I said the book sucked, so there was no mention of "LIKE". Thanks, I'll try that now

//
Thanks, it works fine.

This is definitely the worst taught class I've ever been in. The teacher told us what we had to do, but not how (I understand that happens in the real world, but hey, he's actually supposed to teach us stuff :D), and that everything we needed to know would be in that book. But...meh, what can you do :)

a2jfreak
5 Oct 2003, 11:09 PM
Welcome

Enverex
5 Oct 2003, 11:46 PM
You'll want to use

Select BLAH from BLAH where BLAH = BLAH

too, if you want to pick something out specifically. The %'s are wildcards like * normally. I.e. "Like %Blah" will find eggyblah and blah but not blahstable, opposite with blah%, it will find blashstabe and blah, but not happyblah.

NS

shwaip
5 Oct 2003, 11:50 PM
Thx NS, but that was in the book :).