Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

hibernate sql ²Ù×÷

@SuppressWarnings("unchecked")
    public List<ZxFunction> selectFunctionParentByUserId(final int userId) {
        try {
            final String sql = "select *  from zx_function where f_id in ( select distinct f.f_parent_id from zx_function f,zx_permission p where p.f_id = f.f_id and p.u_id = ?)";
            return (List<ZxFunction>) getHibernateTemplate().execute(new HibernateCallback(){
                public Object doInHibernate(Session session)
                    throws HibernateException, SQLException {
                SQLQuery query = session.createSQLQuery(sql).addEntity(ZxFunction.class);
                query.setInteger(0, 1);
                return query.list();
            }});
        } catch (Exception e) {
            CommonsLog4jUtil.printToConsole(e);
            CommonsLog4jUtil.error("FunctionDaoImpl public List<UserFunction> selectFunctionParentByUserId() Error:", e);
            return null;
        }
    }
@SuppressWarnings("unchecked")
    public List<UserFunction> selectFunction(final int userId) {
        try {
            final String sql = "select f.f_id as FId,&q


Ïà¹ØÎĵµ£º

SqlÊý¾ÝÓÅ»¯·½°¸

1¡¢Ê¹ÓÃË÷ÒýÀ´¸ü¿ìµØ±éÀú±í¡£
ȱʡÇé¿öϽ¨Á¢µÄË÷ÒýÊÇ·ÇȺ¼¯Ë÷Òý£¬µ«ÓÐʱËü²¢²»ÊÇ×î¼ÑµÄ¡£ÔÚ·ÇȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏËæ»ú´æ·ÅÔÚÊý¾ÝÒ³ÉÏ¡£ºÏÀíµÄË÷ÒýÉè¼ÆÒª½¨Á¢ÔÚ¶Ô¸÷ÖÖ²éѯµÄ·ÖÎöºÍÔ¤²âÉÏ¡£
Ò»°ãÀ´Ëµ£º
a.ÓдóÁ¿Öظ´Öµ¡¢ÇÒ¾­³£Óз¶Î§²éѯ£¨ > ,< £¬> =,< =£©ºÍorder by¡¢group by·¢ÉúµÄÁУ¬¿É¿¼
Âǽ ......

ÈýÖÐSQL ·ÖÒ³·½·¨Ð§ÂÊ·ÖÎö

ÈýÖÖSQL·ÖÒ³·¨Ð§ÂÊ·ÖÎö
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
¡¡Óï¾äÐÎʽ£ºÀûÓÃNot InºÍSELECT TOP·ÖÒ³) ЧÂÊÖУ¬ÐèҪƴ½ÓSQLÓï¾ä
  SELECT TOP 10 * from  TestTable WHERE (Id  NOT  IN (SELECT  TOP  20    id&n ......

SQL distinctÓ÷¨¡¡¼òµ¥group by ÃüÁî


distinctÕâ¸ö¹Ø¼ü×ÖÓÃÀ´¹ýÂ˵ô¶àÓàµÄÖظ´¼Ç¼ֻ±£ÁôÒ»Ìõ£¬µ«ÍùÍùÖ»ÓÃËüÀ´·µ»Ø²»Öظ´¼Ç¼µÄÌõÊý£¬¶ø²»ÊÇÓÃËüÀ´·µ»Ø²»ÖؼǼµÄËùÓÐÖµ¡£ÆäÔ­ÒòÊÇdistinctÖ»ÓÐÓöþÖØÑ­»·²éѯÀ´½â¾ö£¬¶øÕâÑù¶ÔÓÚÒ»¸öÊý¾ÝÁ¿·Ç³£´óµÄÕ¾À´Ëµ£¬ÎÞÒÉÊÇ»áÖ±½ÓÓ°Ï쵽ЧÂʵġ£
ÏÂÃæÏÈÀ´¿´¿´Àý×Ó£º
table±í
×Ö¶Î1      ×Ö¶ ......

SQL outputʹÓÃ

SQL°æ£º
alter proc testguo
(
    @cityid int,
    @cityname nvarchar(100) output
)
as
select @cityname =  city_name from BA_Hot_City where cityid = @cityid
select @cityname
go
declare @cityname nvarchar(100)
exec testguo 1,@cityname output
ÁíÒ»°æ£º
ht ......

ÅäÖÃsql server 2000ÔÊÐíÔ¶³Ì·ÃÎÊ

 ÅäÖÃsql server 2000ÒÔÔÊÐíÔ¶³Ì·ÃÎÊÊʺϹÊÕÏ:1. ÓÃsqlÆóÒµ¹ÜÀíÆ÷ÄÜ·ÃÎÊsql server 2000(ÒòΪËüÊDzÉÓÃÃüÃû¹ÜµÀ(named pipes)·½Ê½½øÐз½Ê½),µ«ÓÃado.net ·½Ê½(udp)²»ÄÜ·ÃÎÊ.2. ²ÉÓÃado.net·½Ê½²»ÄÜÔ¶³Ì·ÃÎÊ.¹ÊÕϵĿÉÄÜÔ­ÒòÓÐ:1.sql server 2000ûÓа²×°sql server 2000 sp3a¼°ÒÔÉÏÉý¼¶°ü,»¹Î´ÆôÓò¢¿ª·Å1433¶Ë¿Ú(udp);2 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ