LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-18-2008, 08:46 PM   #1
secretlydead
Member
 
Registered: Sep 2003
Location: Qingdao, China
Distribution: mandriva, slack, red flag
Posts: 248

Rep: Reputation: 31
compare $php variable to indexed distinct mysql columns


i'm writing a program where a php $variable has to be compared to mysql select distinct column1, column2, where column1,column2 has a unique index. how do i write the mysql query for that without using concat?

in other words, i don't want to use, select * from table where $variable = concat(column1,column2); i would like instead to make use of the index.
 
Old 02-18-2008, 10:48 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Do you mean:
1. compare var to all distinct combos of concat(col1,col2)
OR
2. retrieve row where var = concat(col1,col2)
??
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare a variable with line. say_hi_ravi Programming 2 01-29-2008 03:03 AM
maybe simple mysql q: how to tell which column to 'DISTINCT' BrianK Programming 6 12-06-2007 06:52 PM
Why do I get a broken connection when I try to compare SID with a variable (PHP 4) vharishankar Programming 6 07-09-2005 10:57 AM
php mysql variable arguments in query. ldp Linux - Software 0 10-26-2004 07:56 AM
How do you compare variable in bash programming? chynna_v Programming 6 09-08-2004 02:17 AM


All times are GMT -5. The time now is 07:07 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration