Multiple rows in single where … like clauseMultiple Updates in MySQLHow to concatenate text from multiple rows into a single text string in SQL server?Can I concatenate multiple MySQL rows into one field?Parameterize an SQL IN clauseSQL join: where clause vs. on clauseInserting multiple rows in a single SQL query?INNER JOIN ON vs WHERE clauseIs it possible to insert multiple rows at a time in an SQLite database?How to query MongoDB with “like”?Select first row in each GROUP BY group?
How do I tell my girlfriend she's been buying me books by the wrong author for the last nine months?
Why would Dementors torture a Death Eater if they are loyal to Voldemort?
Why is numpy sometimes slower than numpy + plain python loop?
Why did the Apple //e make a hideous noise if you inserted the disk upside down?
Subset of knight's move in chess.
ESTA Elegible after Qatar?
Magento2: Custom module not working
Does a lens with a bigger max. aperture focus faster than a lens with a smaller max. aperture?
Do electrons really perform instantaneous quantum leaps?
Where to connect the fuse and why?
Russian equivalents of 能骗就骗 (if you can cheat, then cheat)
Fully submerged water bath for stove top baking?
Did the Russian Empire have a claim to Sweden? Was there ever a time where they could have pursued it?
A finite 2 group containing the dihedral group of order 16?
Should Catholics in a state of grace call themselves sinners?
"I am [the / an] owner of a bookstore"?
Examples of a lower energy state being a lower entropy state?
What is the meaning of 'shout over' in a sentence exactly?
Word ending in "-ine" for rat-like
Dynamic Sql Query - how to add an int to the code?
Active wildlife outside the window- Good or Bad for Cat psychology?
Why was Pan Am Flight 103 flying over Lockerbie?
What was the point of separating stdout and stderr?
Can I take Amul cottage cheese from India to Netherlands?
Multiple rows in single where … like clause
Multiple Updates in MySQLHow to concatenate text from multiple rows into a single text string in SQL server?Can I concatenate multiple MySQL rows into one field?Parameterize an SQL IN clauseSQL join: where clause vs. on clauseInserting multiple rows in a single SQL query?INNER JOIN ON vs WHERE clauseIs it possible to insert multiple rows at a time in an SQLite database?How to query MongoDB with “like”?Select first row in each GROUP BY group?
I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:
$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
or:
$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
Or do i have to use it like that:
$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";
sql postgresql where sql-like
add a comment |
I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:
$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
or:
$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
Or do i have to use it like that:
$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";
sql postgresql where sql-like
Try something like theANY(array)operator...
– Usagi Miyamoto
Mar 25 at 15:56
ANY()will not work...
– Usagi Miyamoto
Mar 25 at 16:08
add a comment |
I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:
$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
or:
$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
Or do i have to use it like that:
$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";
sql postgresql where sql-like
I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:
$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
or:
$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";
Or do i have to use it like that:
$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";
sql postgresql where sql-like
sql postgresql where sql-like
edited Mar 25 at 15:49
Jared Forth
8371 gold badge5 silver badges20 bronze badges
8371 gold badge5 silver badges20 bronze badges
asked Mar 25 at 15:35
GrimGrim
228 bronze badges
228 bronze badges
Try something like theANY(array)operator...
– Usagi Miyamoto
Mar 25 at 15:56
ANY()will not work...
– Usagi Miyamoto
Mar 25 at 16:08
add a comment |
Try something like theANY(array)operator...
– Usagi Miyamoto
Mar 25 at 15:56
ANY()will not work...
– Usagi Miyamoto
Mar 25 at 16:08
Try something like the
ANY(array) operator...– Usagi Miyamoto
Mar 25 at 15:56
Try something like the
ANY(array) operator...– Usagi Miyamoto
Mar 25 at 15:56
ANY() will not work...– Usagi Miyamoto
Mar 25 at 16:08
ANY() will not work...– Usagi Miyamoto
Mar 25 at 16:08
add a comment |
1 Answer
1
active
oldest
votes
WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)
etc. will work if you're looking for an exact match rather than using LIKE.
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55341357%2fmultiple-rows-in-single-where-like-clause%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)
etc. will work if you're looking for an exact match rather than using LIKE.
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
add a comment |
WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)
etc. will work if you're looking for an exact match rather than using LIKE.
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
add a comment |
WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)
etc. will work if you're looking for an exact match rather than using LIKE.
WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)
etc. will work if you're looking for an exact match rather than using LIKE.
answered Mar 25 at 15:59
anonymousanonymous
182 bronze badges
182 bronze badges
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
add a comment |
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example
– Grim
Mar 25 at 16:26
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
In that case you might want to go with your last example, since you're comparing each different input to a pattern
– anonymous
Mar 25 at 17:06
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55341357%2fmultiple-rows-in-single-where-like-clause%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try something like the
ANY(array)operator...– Usagi Miyamoto
Mar 25 at 15:56
ANY()will not work...– Usagi Miyamoto
Mar 25 at 16:08