Here is the SQL we did in class so far
--this changes the context to the database communityAssist use CommunityAssist; --a select statement that choose fields SELECT Personlastname, PersonfirstName, PersonUserName FROM Person; --the astric * is a wild card saying return all columns --order by sorts, desc sorts in reverse Select * from Person order by PersonLastName desc, PersonFirstname desc; --the where clause limits what "rows" are returned Select * From Person Where PersonLastName = 'Baker'; Select * From Person Where PersonLastName Like '%B%'; Select * from PersonAddress; Select * from PersonAddress where Apartment is not null Select * From ServiceGrant Where GrantAllocation > 400 Select * From ServiceGrant where GrantDate between '2013-08-09' and '2013-08-19' --inner joins join data from two or more related tables Select PersonLastName, PersonFirstname, GrantDate, GrantAmount, ServiceName, GrantNeedExplanation From Person inner join ServiceGrant on Person.PersonKey=ServiceGrant.PersonKey inner Join CommunityService on CommunityService.ServiceKey = ServiceGrant.ServiceKey Where PersonLastName='Anderson'
No comments:
Post a Comment