search only certain columns in 1 table using php
search only certain columns in 1 table using php
am 24.06.2006 18:44:30 von zen72261
Hi
i want to only do a REGEXP against 4 columns in a table
Job_Title | Job_Description | Job_Salary | Job_Location
i tried $sql = "SELECT * FROM Jobs WHERE (Job_Title, Job_Description,
Job_Salary, Job_Location) REGEXP '$search'"
but its not a valid SQL statement. also tried with WHERE (Job_Title OR
Job_Description OR Job_Salary OR Job_Location)
same problem
mysql is 3.23.56 & php4.3.11
i have googled but not found a solution.
Mark
Re: search only certain columns in 1 table using php
am 24.06.2006 18:50:35 von Rik
Mark D. Smith wrote:
> Hi
>
> i want to only do a REGEXP against 4 columns in a table
>
> Job_Title | Job_Description | Job_Salary | Job_Location
>
> i tried $sql = "SELECT * FROM Jobs WHERE (Job_Title, Job_Description,
> Job_Salary, Job_Location) REGEXP '$search'"
>
> but its not a valid SQL statement. also tried with WHERE (Job_Title OR
> Job_Description OR Job_Salary OR Job_Location)
What regex, what does it need to validate?
Maybe:
SELECT * FROM Jobs WHERE CONCAT(Job_Title, Job_Description, Job_Salary,
Job_Location) REGEXP '$search'
or
SELECT * FROM Jobs WHERE Job_Title REGEXP '$search' OR Job_Description
REGEXP '$search' OR Job_Salary REGEXP '$search' OR Job_Location REGEXP
'$search'
Depending on your exact needs. What are you trying to acconbmplish, what
data is in the columns, what is in the regex?
Grtz,
--
Rik Wasmus
Re: search only certain columns in 1 table using php
am 24.06.2006 19:46:31 von zen72261
"Rik" wrote in message
news:8afe9$449d6d0f$8259c69c$13517@news2.tudelft.nl...
> Mark D. Smith wrote:
> > Hi
> >
> > i want to only do a REGEXP against 4 columns in a table
> >
> > Job_Title | Job_Description | Job_Salary | Job_Location
> >
> > i tried $sql = "SELECT * FROM Jobs WHERE (Job_Title, Job_Description,
> > Job_Salary, Job_Location) REGEXP '$search'"
> >
> > but its not a valid SQL statement. also tried with WHERE (Job_Title OR
> > Job_Description OR Job_Salary OR Job_Location)
>
> What regex, what does it need to validate?
> Maybe:
> SELECT * FROM Jobs WHERE CONCAT(Job_Title, Job_Description, Job_Salary,
> Job_Location) REGEXP '$search'
> or
> SELECT * FROM Jobs WHERE Job_Title REGEXP '$search' OR Job_Description
> REGEXP '$search' OR Job_Salary REGEXP '$search' OR Job_Location REGEXP
> '$search'
>
> Depending on your exact needs. What are you trying to acconbmplish, what
> data is in the columns, what is in the regex?
>
> Grtz,
> --
> Rik Wasmus
>
>
Hi
all the columns are longtext and for example in Job_Location it might be
looking for England same could be in Job_Description.
using SELECT * FROM Jobs WHERE CONCAT(Job_Title, Job_Description,
Job_Salary, Job_Location) REGEXP '$search'
looks like it will do as it gets part and whole words. common words in title
& description are Salary & Manager
Mark
Re: search only certain columns in 1 table using php
am 25.06.2006 11:24:58 von zen72261
"Rik" wrote in message
news:8afe9$449d6d0f$8259c69c$13517@news2.tudelft.nl...
> Mark D. Smith wrote:
> > Hi
> >
> > i want to only do a REGEXP against 4 columns in a table
> >
> > Job_Title | Job_Description | Job_Salary | Job_Location
> >
> > i tried $sql = "SELECT * FROM Jobs WHERE (Job_Title, Job_Description,
> > Job_Salary, Job_Location) REGEXP '$search'"
> >
> > but its not a valid SQL statement. also tried with WHERE (Job_Title OR
> > Job_Description OR Job_Salary OR Job_Location)
>
> What regex, what does it need to validate?
> Maybe:
> SELECT * FROM Jobs WHERE CONCAT(Job_Title, Job_Description, Job_Salary,
> Job_Location) REGEXP '$search'
> or
> SELECT * FROM Jobs WHERE Job_Title REGEXP '$search' OR Job_Description
> REGEXP '$search' OR Job_Salary REGEXP '$search' OR Job_Location REGEXP
> '$search'
>
> Depending on your exact needs. What are you trying to acconbmplish, what
> data is in the columns, what is in the regex?
>
> Grtz,
> --
> Rik Wasmus
>
>
I now have a new test the apply
CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src') works but i
need to add a test for where
Job_Location ="$loc" ($loc is a number 1 to 19) currently
tried
WHERE CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src') AND
Job_location ="$loc"
but no luck
Mark
Re: search only certain columns in 1 table using php
am 25.06.2006 19:05:35 von Rik
Mark D. Smith wrote:
> I now have a new test the apply
>
> CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src') works
> but i need to add a test for where
>
> Job_Location ="$loc" ($loc is a number 1 to 19) currently
>
> tried
> WHERE CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src')
> AND Job_location ="$loc"
> but no luck
Echo your query, what does it actually like with the variables?
It should work, what if you try:
WHERE Job_location = "$loc"
Does that return any hits?
Grtz,
--
Rik Wasmus
Re: search only certain columns in 1 table using php
am 25.06.2006 21:22:56 von zen72261
"Rik" wrote in message
news:d3ec6$449ec211$8259c69c$19891@news2.tudelft.nl...
> Mark D. Smith wrote:
> > I now have a new test the apply
> >
> > CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src') works
> > but i need to add a test for where
> >
> > Job_Location ="$loc" ($loc is a number 1 to 19) currently
> >
> > tried
> > WHERE CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src')
> > AND Job_location ="$loc"
> > but no luck
>
> Echo your query, what does it actually like with the variables?
> It should work, what if you try:
> WHERE Job_location = "$loc"
>
> Does that return any hits?
>
> Grtz,
> --
> Rik Wasmus
>
>
Hi
once i removed the extra ) after $scr'
WHERE CONCAT(Job_Title, Job_Description, Job_Salary1) REGEXP '$src' AND
Job_location ="$loc"
the amount of data in the database is a little limited so the first few
$loc's don't hit but later combination of $loc and $src do.
Thanks again all working as i hoped.
Mark