Use case:
sql table contains column with name longText
How can i write a qeury that select a row that contains longText=“asdf”
longText might have a page of text but as long as string “asdf” appears
in that page the row should be selected.
Postgres > Mysql but as features go it is not as powerful as Oracle, not by a longshot. Postgres has four nice things going for it that give it an Oracle feel (1) sequences which are better than auto_increment (2) MVCC means writers don’t block readers when a writer does a SELECT FOR UPDATE (3) No messy table types that only support a specific feature like in MySQL where if you want transaction and referential integrity you have to use INNODB which doesn’t support full-text searching like MyISAM does. (4) proven long-time support of stored procs, triggers and views. This is only recent in MySQL5.
If you want DBMS_JOBS, data partitioning, materialized views, analytics, PLSQL packages(I really miss this in Postgres, it’s a great way to organize your stored procs and functions), BULK_COLLECT(miss this a lot too), rich and easy built-in full-text searching(Postgres requires tsearch or another 3rd party separate app which are not nearly as easy to use), built-in and very easy XML support(3rd party again in Postgres) then you need Oracle.
You can spend a lifetime learning all the features of Oracle.
<sql:query dataSource="jdbc/yourDataSource" var="rs">
SELECT * FROM table WHERE textfield LIKE '%${param.d}%';
</sql:query>
here is actually what I have
<sql:query var="rs" dataSource="jdbc/TestDB">
SELECT *
FROM myTable
WHERE
OR id=?
OR description LIKE '%${param.description}%'
ORDER BY id DESC;
<sql:param value="${param.postId}"/>
</sql:query>
Here if the user does not specify description but only specifies id than it selects ALL rows instead of only one with specified id.
How can I restrict this? So if the user specifies id but does not specify description it selects only one row with specified id?
<sql:query var="rs" dataSource="jdbc/TestDB">
SELECT id, title, d, cost, description, currentDate, isActive
FROM myTable
WHERE d=?
OR id=?
OR cost BETWEEN ? AND ?
OR description LIKE '%${param.description}%'
ORDER BY id DESC;
<sql:param value="${param.d}"/>
<sql:param value="${param.postId}"/>
<sql:param value="${param.from}"/>
<sql:param value="${param.to}"/>
</sql:query>
so if I want to select ONLY by id and do no specify description it gets me all rows instead of the one with id that I specify.
SELECT id, title, d, cost, description, currentDate, isActive
FROM myTable
WHERE d=?
OR id=?
AND (cost BETWEEN ? AND ?
OR description LIKE '%${param.description}%')
ORDER BY id DESC;