Combination Procedure SqlServer UNION,Like For Search


Combination Script SqlServer UNION,Like For Search


EXAMPLE :



SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE [dbo].[Getcari] 

@idiklan nvarchar = 0

,@judul nvarchar = 0

,@nmkategori nvarchar = 0

,@status nvarchar = 0

,@harga nvarchar = 0

,@deskripsi nvarchar = 0

,@UserId nvarchar = 0

AS

BEGIN

SET NOCOUNT ON;

SELECT idiklan,judul,REPLACE(judul,' ','-')[SLUG],nmkategori,status,harga,deskripsi,image1,tglposting,UserId FROM tblproperti WHERE idiklan LIKE '%' + @idiklan + '%' OR judul LIKE '%' + @judul + '%'  OR nmkategori LIKE '%' + @nmkategori + '%' OR status LIKE '%' + @status + '%' OR harga LIKE '%' + @harga + '%' OR deskripsi LIKE '%' + @deskripsi + '%' OR UserId LIKE '%' + @UserId + '%' 

UNION

SELECT idiklan,judul,REPLACE(judul,' ','-')[SLUG],nmkategori,status,harga,deskripsi,image1,tglposting,UserId FROM tblother WHERE idiklan LIKE '%' + @idiklan + '%' OR judul LIKE '%' + @judul + '%' OR nmkategori LIKE '%' + @nmkategori + '%' OR status LIKE '%' + @status + '%' OR harga LIKE '%' + @harga + '%' OR deskripsi LIKE '%' + @deskripsi + '%' OR UserId LIKE '%' + @UserId + '%'

ORDER BY idiklan ASC

END



This Example Working My Home

Tidak ada komentar:

Posting Komentar