473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

query-question

hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?

1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?
therefore I should get the same, or more results...

any hints are greatly appreciated!

TIA,
alex
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #1
9 1498
Hello

|| isn't OR!!

testdb011=> select 'aaaa'||'bbbbbbb';
?column?
-------------
aaaabbbbbbb

This is SQL, not java or C. OR is OR in SQL :->

Pavel
On Thu, 11 Sep 2003, [ISO-8859-1] Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?

1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?
therefore I should get the same, or more results...

any hints are greatly appreciated!

TIA,
alex
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2
|| is the string concatenation operator, so what you're doing is
equivalent to using the concatenated values of those fields.
I have no experience with ILIKE, but you might figure out yourself
what's wrong...

HTH,
Csaba.
On Thu, 2003-09-11 at 13:36, Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?

1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?
therefore I should get the same, or more results...

any hints are greatly appreciated!

TIA,
alex
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #3
|| is the string concatenation operator, so what you're doing is
equivalent to using the concatenated values of those fields.
I have no experience with ILIKE, but you might figure out yourself
what's wrong...

HTH,
Csaba.
On Thu, 2003-09-11 at 13:36, Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?

1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?
therefore I should get the same, or more results...

any hints are greatly appreciated!

TIA,
alex
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #4

On Thu, 11 Sep 2003, [ISO-8859-1] Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?
No, it's string concatenation. Also, remember that NULLs are special
a || NULL is NULL. You can use coalesce(field,"") to get an empty string
if field is NULL.
1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?


And even for OR, the above isn't true in SQL because of NULLs.
1 | 0 | N
1 1 | 1 | N
0 1 | 0 | N
N N | N | N
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #5
Stephan Szabo wrote:
On Thu, 11 Sep 2003, [ISO-8859-1] Alexander Bl?m wrote:

hello,

I'm facing an odd problem.
I have a query:

SELECT "K?rzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"K?rzel"||"Monographie-K?rzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"K?rzel"||"Monographie-K?rzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?

No, it's string concatenation. Also, remember that NULLs are special
a || NULL is NULL. You can use coalesce(field,"") to get an empty string
if field is NULL.

1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?

And even for OR, the above isn't true in SQL because of NULLs.
1 | 0 | N
1 1 | 1 | N
0 1 | 0 | N
N N | N | N


THANK YOU VERY MUCH!!! ;))

that did the deed, exactly as intended!!
now I understand.

thanks again to all of you!

cheers,
alex

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #6

On Thu, 11 Sep 2003, [ISO-8859-1] Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?
No, it's string concatenation. Also, remember that NULLs are special
a || NULL is NULL. You can use coalesce(field,"") to get an empty string
if field is NULL.
1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?


And even for OR, the above isn't true in SQL because of NULLs.
1 | 0 | N
1 1 | 1 | N
0 1 | 0 | N
N N | N | N
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #7
Stephan Szabo wrote:
On Thu, 11 Sep 2003, [ISO-8859-1] Alexander Bl?m wrote:

hello,

I'm facing an odd problem.
I have a query:

SELECT "K?rzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"K?rzel"||"Monographie-K?rzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"K?rzel"||"Monographie-K?rzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?

No, it's string concatenation. Also, remember that NULLs are special
a || NULL is NULL. You can use coalesce(field,"") to get an empty string
if field is NULL.

1 OR 0 = 1
1 OR 1 = 1
0 OR 0 = 0
right?

And even for OR, the above isn't true in SQL because of NULLs.
1 | 0 | N
1 1 | 1 | N
0 1 | 0 | N
N N | N | N


THANK YOU VERY MUCH!!! ;))

that did the deed, exactly as intended!!
now I understand.

thanks again to all of you!

cheers,
alex

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #8
On Thu, 11 Sep 2003, Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?


No. Any component must not be NULL. Use coalesce("Herausgeber",'') to
ensure it's never NULL.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #9
On Thu, 11 Sep 2003, Alexander Blüm wrote:
hello,

I'm facing an odd problem.
I have a query:

SELECT "Kürzel", "Autor(en)", "Titel"
FROM "tblTitelangaben"
WHERE "Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)" ILIKE '%er%';

this works like a charm.

but if I add another ||"something" - which might be emtpy, I get no
results.. why?

WHERE
"Titel"||"Kürzel"||"Monographie-Kürzel"||"Autor(en)"||"Herausgeber"
ILIKE '%er%';

|| is the same as "OR", is it not?


No. Any component must not be NULL. Use coalesce("Herausgeber",'') to
ensure it's never NULL.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
4
by: Diamondback | last post by:
I have two tables, WIDGETS and VERSIONS. The WIDGETS table has descriptive information about the widgets while the VERSIONS table contains IDs relating to different iterations of those widgets...
14
by: Dave Thomas | last post by:
If I have a table set up like this: Name | VARCHAR Email | VARCHAR Age | TINYINT | NULL (Default: NULL) And I want the user to enter his or her name, email, and age - but AGE is optional. ...
2
by: Dom | last post by:
I need to run a query based on a query in Access. The second query has a number of conditions which all work well, but there is one more contition I need to set to make it run properly. the...
5
by: Ryan Hubbard | last post by:
Is it possible to get the recordset from an open query window? So you run the query. The window is open. Can vba retrieve this data?
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.