July 25, 2013 at 5:54 am
Hai friends,
I made on web appplication depends
create table onward_joureny
(
joureny_id int identity,
departuredate datetime,
from varchar(100),
to char(100),
is_draft varchar(100)
)
create table users
(
user_id varchar(100) PK,
username varchar(50),
password varchar(50)
)
create table travel_request
(
request_id int identity,
user_id varchar(100) fk references users(user_id),
total_amount
)
if new requestId means only my data ll shown......
old once not shown be here
is my code correct ah?
--select * from onward_journey where request_id = 58 order by departuredate
--select * from travel_request
create procedure bindata
(
@username varchar(20)
)
as
begin
declare
@user varchar(20),
@request varchar(10)
select @user=a.user_id ,@request=max(b.request_id) from travel_request b inner join users a on a.user_id = b.user_id where a.username=@username group by a.user_id
if exists (select * from travel_request where request_id = @request)
select
onward_journey_id,
convert(varchar, departuredate, 106)as DepartureDate,
from_location,
to_location,
case metro
when 'Yes' then 'Yes' else 'No' end as Metro,
case Trans_All
when 'Yes' then 'Yes' else 'No' END as transit,
case when mode_of_travel like 'Ai%' then mode_of_travel
when mode_of_travel like 'Tr%' then mode_of_travel
when mode_of_travel like 'Bu%' then mode_of_travel
when mode_of_travel like 'Ca%' then mode_of_travel
when mode_of_travel like 'Au%' then mode_of_travel
when mode_of_travel like 'lo%' then mode_of_travel end as Mode,
case when mode_of_travel like ('ai%') then seat_type
when mode_of_travel like ('tra%') then seat_type
when mode_of_travel like ('Bu%') then seat_type
when mode_of_travel like ('ca%') then seat_type
when mode_of_travel like ('au%') then seat_type
when mode_of_travel like ('loc%') then seat_type end as SEAT,
no_of_days as noofdays,
other_details
from
onward_journey
inner join
(
select
a.user_id,
a.userName,
b.request_id
from
users a
inner join
travel_request b
on
a.request_id = b.request_id
where
a.username = @username
)
xx
on
xx.request_id= onward_journey.request_id
where
xx.username=@username
and
xx.request_id = @request
end
July 25, 2013 at 8:03 am
....
is my code correct ah?
...
Test it!
If it's executes wihtout error that mean your code is valid.
Check if results do match expected results. If so, your code is correct.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply