LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 416 users online 221644 members 295 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Forsaken Memories
Interests: Music.
Mood: Lifeless
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
4 online / 14 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

The power of SQL
Replies: 4Last Post June 17 6:11pm by JamesBrauman
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( pleaseremove )


meh

Patron
Tech Support Leader
Reply
OK, I was going to post a question, but given I have solved it there is little need. What however I thought I would post was a quick snippet to show people how powerful even a basic engine like MySQL really is.

Code:

SELECT CONCAT('http://someurl/', reviews.id) AS link,  
filmdb.Film AS title,
DATE_FORMAT(STR_TO_DATE(CONCAT(reviews.day, ',', reviews.month, ',', reviews.year), '%d,%m,%Y'), '%a, %d %b %Y %H:%i:%S +0000') AS date,
CONCAT(reviews.writ, ' reviews ', filmdb.Film) AS description
FROM reviews
JOIN filmdb ON filmdb.id = reviews.id
ORDER BY `reviews`.`id` DESC
LIMIT 0 , 15

Here this is generating each of the items needed for an RSS feed. In this case, because of old poor design of the database the date is stored in 3 fields, day, month and year. This code actually converts them into a correctly formatted datetime for RSS.

People forget you can do casting, string manipulation and conversions etc all in SQL. it makes for often much nicer and faster systems if you get it right.

After all, SQL as it exists in MSSQL and DB2 etc are Turing complete and fully featured programming languages.

Post edited at 6:29 am on May 29, 2009 by pleaseremove

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


6:28 am on May 29, 2009 | Joined: Feb. 2005 | Days Active: 1,299
Join to learn more about pleaseremove England, United Kingdom | Straight Male | Posts: 5,945 | Points: 37,468
LiveWire Humor
Sector Corrupt


Guru

Patron
Tech Support Leader
Reply
Yeah, they're fully featured, It's just more difficult to get the hang of them. Most people don't get into doing databases until they've already got a fair amount of programming experience, and It's a completely different paradigm from what people are used to. Declarative is trickier, or at least looks it to me. I've yet to use SQL though I'll probably be adding a Database to one of my programs so I'll need it then.

-------
Livewire Wifey: Katie :D
Windows, For when you don't know any better.
Mac, for when you think you do.
Linux, for when you actually want to get something done.

6:46 pm on May 29, 2009 | Joined: May 2005 | Days Active: 1,025
Join to learn more about Sector Corrupt Ontario, Canada | Straight Male | Posts: 4,162 | Points: 20,888
matto


Omnipotent One

Patron
Tech Support Leader
Reply
SQL has been very interesting and useful in my limited use of it.  Cool example!

-------
"Say what you like about the tenets of National Socialism, Dude,
at least it's an ethos."
--Walter Sobchak

2:25 pm on May 30, 2009 | Joined: Aug. 2007 | Days Active: 490
Join to learn more about matto California, United States | Male | Posts: 9,804 | Points: 19,066
Spiker19


Dairy Product Addict
Reply
I hate SQL, solely because the tutor who taught us it in university was completely useless and didnt exactly TEACH us it. They simply gave us a big long confusing coursework to do and we basically had to learn the SQL and Coldfusion code ourselves. Something went wrong with my SQL where it just output every record over and over and he didnt even help fix it. Just told me what it was called. Pfft

-------
Only the cool kids snort smarties...

7:49 am on June 10, 2009 | Joined: Feb. 2004 | Days Active: 101
Join to learn more about Spiker19 Scotland, United Kingdom | Gay Male | Posts: 317 | Points: 1,376
JamesBrauman


Connoisseur
Reply
Yeah SQL is great, but kind of confusing if you've never done it before (as opposed to procedural languages).

6:11 pm on June 17, 2009 | Joined: Nov. 2005 | Days Active: 202
Join to learn more about JamesBrauman Australia | Straight Male | Posts: 5,770 | Points: 7,652
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic