ÔÚ SQl SERVER 2005Öе÷Óõ±Ç°Óû§£É£Ä
ÎÊÌ⣺
ÎÒÏÖÔÚÄÚÈݶ¼µ÷ÓóöÀ´ÁË ¾ÍÊÇΨһµÄÒ»¸öÎÊÌâ¡¡¡¡ÎÒÒªµ÷µ±Ç°Óû§ID¡¡ÎÒÓõÄPHPCMS {$r[userid]}Õâ¸ö±äÁ¿ ÔÚSqlServerÉϵ÷Óò»µ½
$sql="SELECT CustomerID, Carid, TotolPoints, TakePoints, LeavingPoints, CarType,Activation,Consumption
from dbo.CardTable¡¡WHERE (CustomerID = id)";
idÒªÊǸö±äÁ¿
»Ø´ð£º
SUSER_SID()£¨²»´ø login_account ²ÎÊýµÄÖ¸¶¨ SUSER_SID£©£¬ÓÃÓÚ»ñµÃµ±Ç°Á¬½ÓµÄ security_identifier£¬²»¹ÜÊÇ·ñʹÓà SQL Server Éí·ÝÑéÖ¤»ò Windows Éí·ÝÑéÖ¤¡£
ÕâÊÇ»ñµÃµ±Ç°Á¬½ÓµÄ°²È«£É£Ä
Sql Server ÖУ¬µ±Ç°Á¬½Óµ½Êý¾Ý¿âµÄÓû§IDÊÇÓú¯Êý»ñµÃµÄ
·µ»ØÓû§ÃûºÍÓû§ ID µÄº¯Êý_ѧԺƵµÀ_school.it168.com
< id="hhobj_1" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_1" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
< id="hhobj_2" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_2" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
< id="hhobj_3" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_3" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
< id="hhobj_4" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_4" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
< id="hhobj_5" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_5" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
< id="hhobj_6" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_6" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
< id="hhobj_7" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" id="hhobj_7" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
·µ»ØÓû§ÃûºÍÓû§ ID
µÄº¯Êý
Óм¸¸öϵͳº¯Êý¿É·µ»ØÓû§ÃûºÍÓû§ ID¡£ÒªÀí½âÕâЩº¯ÊýµÄ²ÎÊýºÍÊä³ö½á¹û
Ïà¹ØÎĵµ£º
1.ÔÚmssql´´½¨´æ´¢¹ý³Ì,ÔÚdb->´æ´¢¹ý³Ì->н¨´æ´¢¹ý³Ì(ÓÒ¼ü)
CREATE PROCEDURE user_logon_check @username varchar(45),@userpsw varchar(45)
AS
select * from users where UserName = @username and PasswordCode = @userpsw
return 10
GO
2.ÔÚmysql´´½¨´æ´¢¹ý³Ì,ʹÓÃMysql Query Browser,ÔÚdb->±í ......
--SQL Server£º
Select TOP N * from TABLE Order By NewID()
--Access£º
Select TOP N * from TABLE Order By Rnd(ID)
Rnd(ID) ÆäÖеÄIDÊÇ×Ô¶¯±àºÅ×ֶΣ¬¿ÉÒÔÀûÓÃÆäËûÈκÎÊýÖµÀ´Íê³É£¬±ÈÈçÓÃÐÕÃû×Ö¶Î(U ......
±àÂë¹ý³ÌÖÐÓöµ½µÄSQL·ÖÒ³Çé¿ö£¬×ܽ᣺
´ÓÊý¾Ý¿â±íÖеÚMÌõ¼Ç¼¿ªÊ¼¼ìË÷NÌõ¼Ç¼
MySQL£º
ÏȲéѯ·ÖÒ³£¬È»ºóÅÅÐò£º
select * from (select * from student limit 5,2) pageTable order by id desc ;
ÏÈÅÅÐò£¬È»ºó²éѯ·ÖÒ³£ºselect * from student order by id desc limit 5,2 ;
Oracle£º
SELECT * fro ......
1¡¢¼òµ¥²éѯ
Çó³öÔÚ1988ÄêÒÔÇ°±»¹ÍÓ¶µÄÏúÊÛÈËÔ±
SELECT NAME
from SALESREPS
WHERE HIRE_DATE<'01-JAN-88'
ÁгöÆäÏúÊÛÁ¿µÍÓÚÏúÊÛÄ¿±êµÄ80%µÄÏúÊÛµã
SELECT CITY,SALES,TAGET
from SALESPEPS
WHERE SALES<0.8*TAGET ......
SQLÓï¾ä¼¶±ðµÄÓÅ»¯ÊÇÎÒÃÇʵ¼Ê¹¤×÷ÖнӴ¥×î¶àµÄ£¬¼¸ºõËùÓеÄÊý¾Ý¿âÓ¦ÓÃ˵µ½µ×¶¼ÊÇSQLÓï¾äµÄ¾ßÌåÖ´ÐУ¬Òò´ËÈçºÎ¶ÔSQL½Å±¾±¾Éí½øÐÐÓÅ»¯£¬Ìá¸ßÖ´ÐÐЧÂʾÍÏÔµÃÓÈΪÖØÒª¡£ÒÔÏÂÊÇһЩͨÓõÄÉè¼ÆÔÔò¡£
(1)ʹÓÃselectÓï¾ä²éѯʱ£¬¾¡Á¿²»ÒªÊ¹ÓÃselect *¡¡Óï¾ä£¬¶øÊÇÓ¦¸ÃÖ¸Ã÷¾ßÌåÒª²éѯµÄ×ֶΣ¬ÌáÈ¡µÄ×Ö¶ÎÊýÁ¿Ô½É ......