Re: Challenge!!!
Posted in 1994
}From: storm@aztec.co.za (Storm Software)
}Subject: Challenge!!!
}Date: 6 Dec 1994 14:48:58 GMT
}X-Informix-List-Id: <news.10136>
}
}Ok...I have a customer with a stock code of '14" Mono'. The challenge is
}to execute an SQL statement that retrieves this row from the stock table.
}
}Ok guys, I am sure you're all thinking along the lines of
}
} select * from stock
} where stock_code matches "14\\" Mono"
}
}but that doesn't work.
}
}Don't cheat now, I want to use 'matches' because I could be searching
}for 14" anythings and you can't use '?' for the quote.
}
}The challenge is there...
Gosh, I wish all the questions were this easy. You ruled out
using ? in the MATCHES clause, so there are two 'obvious' answers.
-- ANSI compliant
SELECT * FROM stock WHERE stock_code MATCHES '14" Mono'; -- Informix extension
SELECT * FROM stock WHERE stock_code MATCHES "14"" Mono";
If you needed to be ANSI compliant and to select a 14 foot Mono-hull, then
you'd use:
SELECT * FROM stock WHERE stock_code MATCHES '14'' Mono-hull';
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>