Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2006, 09:00 AM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Quotes in query; help needed!

I'm working on a CMS and it's almost finished now, but I encountered a problem.

Althroughout the code I've used query's like:
Code:
SELECT name FROM users WHERE name='test';
But now, when I copied the app to the server online, an external host, it gives me errors. Now I have to use:
Code:
SELECT 'name' FROM users WHERE name='test';
Is there a way to tell MySQL to act normal, like my localhost does; and to stop complaining about the absence of quotes?

 
Old November 7th, 2006, 11:39 PM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default

Dear Hylmar,
I never seen to use quote (' ') in table or field name. I have seen using `` .
So your statement should be:
SELECT `name` FROM `users` WHERE name='test';

if you write this statement: SELECT 'name' FROM users WHERE name='test'; you should get name itself as value not any value in the name column.

So far I know, its a better practice to use quotes for value and `` for fields, tables

Best Regard:
Md. Zakir Hossain (Raju)

www.rajuru.xenexbd.com - my blog with PHP scripts, PHP Book Review and many more
 
Old December 7th, 2006, 02:30 AM
Authorized User
 
Join Date: Nov 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to talk2leo
Default

simply u can wtite

select name from users whre name ='test';

no error u will get

Success is Never Ending,,Filure is Never Fimal
 
Old December 21st, 2006, 11:37 PM
Authorized User
 
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to paagle
Default

using quotes is better as all versions of mysql understand that
gives out lesser problems
must be made a habit

---
Paagle
TEAM LEADER-Team Xuberance(http://www.xuberance.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed with JOIN Query icecrew SQL Server 2000 3 October 16th, 2006 11:59 AM
displaying single quotes and double quotes ren_123 Classic ASP Databases 2 February 22nd, 2006 02:17 PM
Help needed with calculation in a query Lovegroover Access 6 August 18th, 2005 10:57 AM
Query for two conditions needed doosti SQL Language 2 November 9th, 2004 06:24 AM
Double Quotes and Single Quotes Problem phungleon Classic ASP Basics 7 May 27th, 2004 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.