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?













0















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.")
";









share|improve this question
























  • 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















0















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.")
";









share|improve this question
























  • 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













0












0








0








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.")
";









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 the ANY(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











  • 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










1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer























  • 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










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
);



);













draft saved

draft discarded


















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









0














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.






share|improve this answer























  • 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















0














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.






share|improve this answer























  • 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













0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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






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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?