Database issues

1. long string inserted into sql server.

insert into tbtest (text) values ('abc\'ff\r\ndef')

 

2. district in conjunction with the orderby

sql="select distinct id from test order by otherfield desc"  

Need to find a different id, at the same time we want the records sorted by fbsj. But certainly this error occurs, distinct and order by conflicts arise. How to get the perfect solution yet, look at the following methods, still with a sql statement

sql="select id from test group by id order by max(otherfield) desc" 

Instead of disitnct with the group by id realize find different functions.

Guess you like

Origin www.cnblogs.com/connie313/p/12013690.html